This is an example of converting the "gate" and "execute" functions of
a pass into C++ virtual functions, so that in the next patch we can move
a variable into member data of the opt_pass subclass.

gcc/testsuite/

        * gcc.dg/plugin/one_time_plugin.c: (one_pass_gate): convert
        to member function...
        (one_pass::gate): ...this
        (one_pass_exec): convert to member function...
        (one_pass::impl_execute): ...this
---
 gcc/testsuite/gcc.dg/plugin/one_time_plugin.c | 36 +++++++++++++--------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c 
b/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
index 2d996da..7e93e65 100644
--- a/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
@@ -12,22 +12,6 @@
 
 int plugin_is_GPL_compatible;
 
-static bool one_pass_gate (void)
-{
-  return true;
-}
-
-static unsigned int one_pass_exec (void)
-{
-  static int counter = 0;
-
-  if (counter > 0) {
-    printf ("Executed more than once \n");
- }
- counter++;
- return 0;
-}
-
 namespace {
 
 const pass_data pass_data_one_pass =
@@ -53,13 +37,29 @@ public:
   {}
 
   /* opt_pass methods: */
-  bool gate () { return one_pass_gate (); }
-  unsigned int execute () { return one_pass_exec (); }
+  bool gate ();
+  unsigned int execute ();
 
 }; // class one_pass
 
 } // anon namespace
 
+bool one_pass::gate (void)
+{
+  return true;
+}
+
+unsigned int one_pass::execute ()
+{
+  static int counter = 0;
+
+  if (counter > 0) {
+    printf ("Executed more than once \n");
+ }
+ counter++;
+ return 0;
+}
+
 gimple_opt_pass *
 make_one_pass (gcc::context *ctxt)
 {
-- 
1.7.11.7

Reply via email to