[cfe-commits] r172834 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp test/Parser/cxx-decl.cpp

Nico Weber nicolasweber at gmx.de
Fri Jan 18 10:41:42 PST 2013


Author: nico
Date: Fri Jan 18 12:41:42 2013
New Revision: 172834

URL: http://llvm.org/viewvc/llvm-project?rev=172834&view=rev
Log:
Fix parsing of class specifiers before '\n' 'operator'.

r159549 / r159164 regressed clang to reject

  struct s {};
  struct s
  operator++(struct s a)
  { return a; }

This fixes the regression. Richard, pleas check if this looks right.


Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/Parser/cxx-decl.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=172834&r1=172833&r2=172834&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Jan 18 12:41:42 2013
@@ -964,6 +964,7 @@
   case tok::annot_template_id:  // struct foo {...} a<int>    ::b;
   case tok::l_paren:            // struct foo {...} (         x);
   case tok::comma:              // __builtin_offsetof(struct foo{...} ,
+  case tok::kw_operator:        // struct foo operator++() {...}
     return true;
   case tok::colon:
     return CouldBeBitfield;     // enum E { ... }   :         2;

Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=172834&r1=172833&r2=172834&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Fri Jan 18 12:41:42 2013
@@ -132,6 +132,24 @@
   typedef S() : n(1), m(2) { } // expected-error {{function definition declared 'typedef'}}
 };
 
+
+namespace TestIsValidAfterTypeSpecifier {
+struct s {};
+
+namespace a {
+struct s operator++(struct s a)
+{ return a; }
+}
+
+namespace b {
+// The newline after s should make no difference.
+struct s
+operator++(struct s a)
+{ return a; }
+}
+
+}
+
 // PR8380
 extern ""      // expected-error {{unknown linkage language}}
 test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \





More information about the cfe-commits mailing list