[PATCH/C++/diagnostic] Be extra pedantic about stray semicolons

Dirk Mueller dmueller@suse.de
Thu Mar 15 02:53:00 GMT 2007


recently I've been pointed out that there is an inconsistency in the "stray 
semicolon" pedwarn. While it warns about stray semicolons here: 

void foo()
}; // <- warning

it does not warn if its inside a class:

class bla {
   void foo()
   }; // <- no warning

Fixing that is straight forward, however causes about 120 regressions, which 
are all really boring, except one: g++.old-deja/g++.brendan/warnings2.C. 

This testcase reads: 

=== Cut ===
// { dg-do assemble  }
// GROUPS passed warnings
class K {
        void f() {
        }; // there should be no warning about this semicolon
=== Cut ===

Given that it doesn't define dg-options, it gets default options, which 
contains among other flags -pedantic -pedantic-errors, and will therefore 
trigger a failure now. 

I couldn't figure out via mailing list searching or svn log why this testcase 
is there, it has been added longer ago than the svn history serves. I think 
it should test that there is no warning by default, e.g. even when 
using -Wall -Wextra.

The patch below changes the testcase accordingly. Comments? Opinions?
Ok for trunk?

2007-03-15  Dirk Mueller  <dmueller@suse.de>

        * g++.old-deja/g++.brendan/warnings2.C: Compile
        with -Wall -Wextra -Werror, not with -pedantic.

--- g++.old-deja/g++.brendan/warnings2.C
+++ g++.old-deja/g++.brendan/warnings2.C
@@ -1,4 +1,5 @@
-// { dg-do assemble  }
+// { dg-do compile  }
+// { dg-options "-Wall -Wextra -Werror" }
 // GROUPS passed warnings
 class K {

More information about the Gcc-patches mailing list