OSDN Git Service

635776fc5bc9584af539396234262eb0b4587499
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / plugin / one_time_plugin.c
1 /* Plugin that prints message if it inserted (and invoked) more than once. */
2 #include "config.h"
3 #include "gcc-plugin.h"
4 #include "system.h"
5 #include "coretypes.h"
6 #include "tm.h"
7 #include "toplev.h"
8 #include "gimple.h"
9 #include "tree-pass.h"
10 #include "intl.h"
11
12 int plugin_is_GPL_compatible;
13
14 static bool one_pass_gate (void)
15 {
16   return true;
17 }
18
19 static unsigned int one_pass_exec (void)
20 {
21   static int counter = 0;
22
23   if (counter > 0) {
24     printf ("Executed more than once \n");
25  }
26  counter++;
27 }
28
29 struct gimple_opt_pass one_pass = 
30 {
31   {
32   GIMPLE_PASS,
33   "useless",                           /* name */
34   one_pass_gate,                         /* gate */
35   one_pass_exec,       /* execute */
36   NULL,                                 /* sub */
37   NULL,                                 /* next */
38   0,                                    /* static_pass_number */
39   0,                                    /* tv_id */
40   PROP_gimple_any,                      /* properties_required */
41   0,                                    /* properties_provided */
42   0,                                    /* properties_destroyed */
43   0,                                    /* todo_flags_start */
44   TODO_dump_func                        /* todo_flags_finish */
45   }
46 };
47
48
49 int plugin_init (struct plugin_name_args *plugin_info,
50                  struct plugin_gcc_version *version)
51 {
52   struct plugin_pass p;
53
54   p.pass = &one_pass.pass;
55   p.reference_pass_name = "useless";
56   p.ref_pass_instance_number = 1;
57   p.pos_op = PASS_POS_INSERT_AFTER;
58
59   register_callback ("one_pass", PLUGIN_PASS_MANAGER_SETUP, NULL, &p);
60
61   return 0;
62 }