Small ChangeLog tweak.
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / one_time_plugin.c
blobbd1c0f0e57948e995f1b63d89be12a3512701926
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 "tree.h"
7 #include "tm.h"
8 #include "toplev.h"
9 #include "hash-table.h"
10 #include "vec.h"
11 #include "ggc.h"
12 #include "basic-block.h"
13 #include "tree-ssa-alias.h"
14 #include "internal-fn.h"
15 #include "gimple-fold.h"
16 #include "tree-eh.h"
17 #include "gimple-expr.h"
18 #include "is-a.h"
19 #include "gimple.h"
20 #include "tree-pass.h"
21 #include "intl.h"
22 #include "context.h"
24 int plugin_is_GPL_compatible;
26 namespace {
28 const pass_data pass_data_one_pass =
30 GIMPLE_PASS, /* type */
31 "cfg", /* name */
32 OPTGROUP_NONE, /* optinfo_flags */
33 TV_NONE, /* tv_id */
34 PROP_gimple_any, /* properties_required */
35 0, /* properties_provided */
36 0, /* properties_destroyed */
37 0, /* todo_flags_start */
38 0, /* todo_flags_finish */
41 class one_pass : public gimple_opt_pass
43 public:
44 one_pass(gcc::context *ctxt)
45 : gimple_opt_pass(pass_data_one_pass, ctxt),
46 counter(0)
49 /* opt_pass methods: */
50 virtual bool gate (function *);
51 virtual unsigned int execute (function *);
53 private:
54 int counter;
55 }; // class one_pass
57 } // anon namespace
59 bool one_pass::gate (function *)
61 return true;
64 unsigned int
65 one_pass::execute (function *)
67 if (counter > 0) {
68 printf ("Executed more than once \n");
70 counter++;
71 return 0;
74 gimple_opt_pass *
75 make_one_pass (gcc::context *ctxt)
77 return new one_pass (ctxt);
81 int plugin_init (struct plugin_name_args *plugin_info,
82 struct plugin_gcc_version *version)
84 struct register_pass_info p;
86 p.pass = make_one_pass (g);
87 p.reference_pass_name = "cfg";
88 p.ref_pass_instance_number = 1;
89 p.pos_op = PASS_POS_INSERT_AFTER;
91 register_callback ("one_pass", PLUGIN_PASS_MANAGER_SETUP, NULL, &p);
93 return 0;