aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2013-08-13 00:45:27 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2013-08-13 00:45:27 +0000
commit3944d88d35e71f0aaf58c2c82bc7cf34414cb6ac (patch)
tree781c743dbfc59857fc8546c78365b19a3a58d137 /gcc
parentb338b23f8875f26f1c4f598faac6c36874ae48f2 (diff)
downloadgcc-3944d88d35e71f0aaf58c2c82bc7cf34414cb6ac.zip
gcc-3944d88d35e71f0aaf58c2c82bc7cf34414cb6ac.tar.gz
gcc-3944d88d35e71f0aaf58c2c82bc7cf34414cb6ac.tar.bz2
Example of converting global state to per-pass state.
gcc/testsuite 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. From-SVN: r201681
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/plugin/one_time_plugin.c7
2 files changed, 12 insertions, 3 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6b82931..bc45fdb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,13 @@
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
to member function...
(one_pass::gate): ...this.
diff --git a/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c b/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
index 7e93e65..c4dace5 100644
--- a/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
@@ -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");
}