1 /* This plugin tests the correct operation of a PLUGIN_START_UNIT callback.
2 * By the time a PLUGIN_START_UNIT callback is invoked, the frontend
3 * initialization should have completed. At least the different *_type_nodes
4 * should have been created. This plugin creates an artificial global
8 #include "gcc-plugin.h"
11 #include "coretypes.h"
14 #include "stringpool.h"
16 #include "basic-block.h"
17 #include "hash-table.h"
20 #include "basic-block.h"
21 #include "tree-ssa-alias.h"
22 #include "internal-fn.h"
23 #include "gimple-fold.h"
25 #include "gimple-expr.h"
29 #include "tree-pass.h"
32 int plugin_is_GPL_compatible
;
33 static tree fake_var
= NULL
;
36 gate_start_unit (void)
41 static void start_unit_callback (void *gcc_data
, void *user_data
)
43 if (integer_type_node
) {
44 fake_var
= build_decl (UNKNOWN_LOCATION
, VAR_DECL
,
45 get_identifier ("_fake_var_"),
47 TREE_PUBLIC (fake_var
) = 1;
48 DECL_ARTIFICIAL (fake_var
) = 1;
52 static void finish_unit_callback (void *gcc_data
, void *user_data
)
54 if (fake_var
== NULL
) {
55 printf ("fake_var not created \n");
58 if (TREE_CODE (fake_var
) != VAR_DECL
) {
59 printf ("fake_var not a VAR_DECL \n");
62 if (TREE_CODE (TREE_TYPE (fake_var
)) != INTEGER_TYPE
) {
63 printf ("fake_var not INTEGER_TYPE \n");
66 if (DECL_ARTIFICIAL (fake_var
) == 0) {
67 printf ("fake_var not ARTIFICIAL \n");
72 int plugin_init (struct plugin_name_args
*plugin_info
,
73 struct plugin_gcc_version
*version
)
75 register_callback ("start_unit", PLUGIN_START_UNIT
, &start_unit_callback
, NULL
);
76 register_callback ("finish_unit", PLUGIN_FINISH_UNIT
, &finish_unit_callback
, NULL
);