]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/testsuite
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Aug 2013 00:45:27 +0000 (00:45 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Aug 2013 00:45:27 +0000 (00:45 +0000)
2013-08-13  David Malcolm  <dmalcolm@redhat.com>

Example of converting global state to per-pass state.

* gcc.dg/plugin/one_time_plugin.c (one_pass::execute): Convert
global state "static int counter" to...
(one_pass::counter): ...this instance data.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201681 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/plugin/one_time_plugin.c

index 6b82931ca8f4b2dcc0316e98415a280cbb76164e..bc45fdb6b25e54a0d2083910c733f8fb00e426cf 100644 (file)
@@ -1,3 +1,11 @@
+2013-08-13  David Malcolm  <dmalcolm@redhat.com>
+
+       Example of converting global state to per-pass state.
+
+       * gcc.dg/plugin/one_time_plugin.c (one_pass::execute): Convert
+       global state "static int counter" to...
+       (one_pass::counter): ...this instance data.
+
 2013-08-13  David Malcolm  <dmalcolm@redhat.com>
 
        * gcc.dg/plugin/one_time_plugin.c: (one_pass_gate): Convert
index 7e93e658500725d30333576f3a741d199ecfbbe3..c4dace5ab27f5878cade678145bc0e2c2554812b 100644 (file)
@@ -33,13 +33,16 @@ class one_pass : public gimple_opt_pass
 {
 public:
   one_pass(gcc::context *ctxt)
-    : gimple_opt_pass(pass_data_one_pass, ctxt)
+    : gimple_opt_pass(pass_data_one_pass, ctxt),
+      counter(0)
   {}
 
   /* opt_pass methods: */
   bool gate ();
   unsigned int execute ();
 
+private:
+  int counter;
 }; // class one_pass
 
 } // anon namespace
@@ -51,8 +54,6 @@ bool one_pass::gate (void)
 
 unsigned int one_pass::execute ()
 {
-  static int counter = 0;
-
   if (counter > 0) {
     printf ("Executed more than once \n");
  }