@@ -1,5 +1,12 @@
2013-04-19 David Malcolm <dmalcolm@redhat.com>
+ * testsuite/gcc.dg/plugin/one_time_plugin.c (one_pass_gate): example
+ of converting global state to per-pass state: convert the
+ "static int counter" within the one_pass::execute hook from having
+ global lifetime to being a field of the pass instance
+
+2013-04-17 David Malcolm <dmalcolm@redhat.com>
+
* testsuite/gcc.dg/plugin/one_time_plugin.c (one_pass_gate): convert
to a virtual function: one_pass::gate
(one_pass_exec): convert to a virtual function: one_pass::impl_execute
@@ -24,7 +24,8 @@ public:
provided(0),
destroyed(0)),
pass_todo_flags(start(0),
- finish(0)))
+ finish(0))),
+ counter(0)
{}
/* opt_pass methods: */
@@ -34,6 +35,8 @@ public:
bool has_execute () { return true; }
unsigned int impl_execute ();
+private:
+ int counter;
}; // class one_pass
bool one_pass::gate (void)
@@ -43,8 +46,6 @@ bool one_pass::gate (void)
unsigned int one_pass::impl_execute ()
{
- static int counter = 0;
-
if (counter > 0) {
printf ("Executed more than once \n");
}