OSDN Git Service

8ae327a68f9b48b2a3322de67ea3869fcbaecc8e
[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 static bool one_pass_gate (void)
13 {
14   return true;
15 }
16
17 static unsigned int one_pass_exec (void)
18 {
19   static int counter = 0;
20
21   if (counter > 0) {
22     printf ("Executed more than once \n");
23  }
24  counter++;
25 }
26
27 struct gimple_opt_pass one_pass = 
28 {
29   {
30   GIMPLE_PASS,
31   "useless",                           /* name */
32   one_pass_gate,                         /* gate */
33   one_pass_exec,       /* execute */
34   NULL,                                 /* sub */
35   NULL,                                 /* next */
36   0,                                    /* static_pass_number */
37   0,                                    /* tv_id */
38   PROP_gimple_any,                      /* properties_required */
39   0,                                    /* properties_provided */
40   0,                                    /* properties_destroyed */
41   0,                                    /* todo_flags_start */
42   TODO_dump_func                        /* todo_flags_finish */
43   }
44 };
45
46
47 int plugin_init (struct plugin_name_args *plugin_info,
48                  struct plugin_gcc_version *version)
49 {
50   struct plugin_pass p;
51
52   p.pass = &one_pass.pass;
53   p.reference_pass_name = "useless";
54   p.ref_pass_instance_number = 1;
55   p.pos_op = PASS_POS_INSERT_AFTER;
56
57   register_callback ("one_pass", PLUGIN_PASS_MANAGER_SETUP, NULL, &p);
58
59   return 0;
60 }