2013-04-17  David Malcolm  <dmalc...@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
---
 gcc/ChangeLog                                 | 7 +++++++
 gcc/testsuite/gcc.dg/plugin/one_time_plugin.c | 7 ++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8554fb3..88b95b8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
 2013-04-19  David Malcolm  <dmalc...@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  <dmalc...@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
diff --git a/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c 
b/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
index 2be2d80..53446f9 100644
--- a/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
@@ -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");
  }
-- 
1.7.11.7

Reply via email to