diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-15 04:56:06 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-15 04:56:06 +0000 |
commit | 8da637123e80be2156e84d0f2f1be564132996c1 (patch) | |
tree | 3ff18ff7fc94a7ca0a414c165e33d5a33108b3f3 /gcc/testsuite/g++.dg/plugin | |
parent | 8eafe656d06910682748b4f19ea12cd8bbabd4ba (diff) | |
download | gcc-8da637123e80be2156e84d0f2f1be564132996c1.tar.gz |
2009-05-15 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r147550
2009-05-15 Basile Starynkevitch <basile@starynkevitch.net>
merged with trunk rev147539
* gcc/melt/warmelt-normal.melt (normexp_defcmatcher): use obj_hash
instead of hashcode!
* gcc/Makefile.in: TEXI_GCCINT_FILES has both plugins.texi & melt.texi
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@147552 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg/plugin')
-rw-r--r-- | gcc/testsuite/g++.dg/plugin/attribute_plugin-test-1.C | 16 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/plugin/attribute_plugin.c | 66 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/plugin/dumb_plugin.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/plugin/plugin.exp | 1 |
4 files changed, 84 insertions, 1 deletions
diff --git a/gcc/testsuite/g++.dg/plugin/attribute_plugin-test-1.C b/gcc/testsuite/g++.dg/plugin/attribute_plugin-test-1.C new file mode 100644 index 00000000000..abb1328670a --- /dev/null +++ b/gcc/testsuite/g++.dg/plugin/attribute_plugin-test-1.C @@ -0,0 +1,16 @@ +// { dg-warning "Callback to register attributes" } + +void normal_func (char c, char c2); +void normal_func (char __attribute__((user("param"))) c, char); +void normal_func (char c, char __attribute__((user("param"))) c2) +{ +} // { dg-warning "attribute 'user' on param 'c' of function normal_func" } +// { dg-warning "attribute 'user' on param 'c2' of function normal_func" "" { target *-*-* } 7 } + +class Foo { + void method (char __attribute__((user("param"))) c); +}; + +void Foo::method(char c) +{ +} // { dg-warning "attribute 'user' on param 'c' of function method" } diff --git a/gcc/testsuite/g++.dg/plugin/attribute_plugin.c b/gcc/testsuite/g++.dg/plugin/attribute_plugin.c new file mode 100644 index 00000000000..d071762102b --- /dev/null +++ b/gcc/testsuite/g++.dg/plugin/attribute_plugin.c @@ -0,0 +1,66 @@ +/* Demonstrates how to add custom attributes */ + +#include <stdlib.h> +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "tree-pass.h" +#include "intl.h" +#include "gcc-plugin.h" + +/* Attribute handler callback */ + +static tree +handle_user_attribute (tree *node, tree name, tree args, + int flags, bool *no_add_attrs) +{ + return NULL_TREE; +} + +/* Attribute definition */ + +static struct attribute_spec user_attr = + { "user", 1, 1, false, false, false, handle_user_attribute }; + +/* Plugin callback called during attribute registration */ + +static void +register_attributes (void *event_data, void *data) +{ + warning (0, G_("Callback to register attributes")); + register_attribute (&user_attr); +} + +/* Callback function to invoke before the function body is genericized. */ + +void +handle_pre_generic (void *event_data, void *data) +{ + tree fndecl = (tree) event_data; + tree arg; + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN (arg)) { + tree attr; + for (attr = DECL_ATTRIBUTES (arg); attr; attr = TREE_CHAIN (attr)) { + tree attrname = TREE_PURPOSE (attr); + tree attrargs = TREE_VALUE (attr); + warning (0, G_("attribute '%s' on param '%s' of function %s"), + IDENTIFIER_POINTER (attrname), + IDENTIFIER_POINTER (DECL_NAME (arg)), + IDENTIFIER_POINTER (DECL_NAME (fndecl)) + ); + } + } +} + +int +plugin_init (const char *plugin_name, + struct plugin_gcc_version *version, + int argc, struct plugin_argument *argv) +{ + register_callback (plugin_name, PLUGIN_CXX_CP_PRE_GENERICIZE, + handle_pre_generic, NULL); + + register_callback (plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL); + return 0; +} diff --git a/gcc/testsuite/g++.dg/plugin/dumb_plugin.c b/gcc/testsuite/g++.dg/plugin/dumb_plugin.c index 0c62f89e109..839dc2b1c8a 100644 --- a/gcc/testsuite/g++.dg/plugin/dumb_plugin.c +++ b/gcc/testsuite/g++.dg/plugin/dumb_plugin.c @@ -21,7 +21,7 @@ handle_struct (void *event_data, void *data) IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)))); } -/* Callback function to invoke before the program is genericized. */ +/* Callback function to invoke before the function body is genericized. */ void handle_pre_generic (void *event_data, void *data) diff --git a/gcc/testsuite/g++.dg/plugin/plugin.exp b/gcc/testsuite/g++.dg/plugin/plugin.exp index e1f6d89ae28..eb019986ffe 100644 --- a/gcc/testsuite/g++.dg/plugin/plugin.exp +++ b/gcc/testsuite/g++.dg/plugin/plugin.exp @@ -47,6 +47,7 @@ load_lib plugin-support.exp # Specify the plugin source file and the associated test files in a list. # plugin_test_list={ {plugin1 test1 test2 ...} {plugin2 test1 ...} ... } set plugin_test_list [list \ + { attribute_plugin.c attribute_plugin-test-1.C } \ { selfassign.c self-assign-test-1.C self-assign-test-2.C self-assign-test-3.C } \ { dumb_plugin.c dumb-plugin-test-1.C } ] |