1 /* A plugin example that shows which declarations are caught by FINISH_DECL */
3 #include "gcc-plugin.h"
11 #include "diagnostic.h"
13 int plugin_is_GPL_compatible
;
15 /* Callback function to invoke after GCC finishes a declaration. */
17 void plugin_finish_decl (void *event_data
, void *data
)
19 tree decl
= (tree
) event_data
;
21 const char *kind
= NULL
;
22 switch (TREE_CODE(decl
)) {
24 kind
= "Function"; break;
26 kind
= "Parameter"; break;
28 if (DECL_FILE_SCOPE_P(decl
))
34 kind
= "Field"; break;
39 warning (0, G_("Decl %s %s"),
40 kind
, IDENTIFIER_POINTER (DECL_NAME (decl
)));
44 plugin_init (struct plugin_name_args
*plugin_info
,
45 struct plugin_gcc_version
*version
)
47 const char *plugin_name
= plugin_info
->base_name
;
49 register_callback (plugin_name
, PLUGIN_FINISH_DECL
,
50 plugin_finish_decl
, NULL
);