r215520 - PR20634: add some more cases that can legitimately come after a struct declaration to our list of special cases.

Richard Smith richard-llvm at metafoo.co.uk
Tue Aug 12 19:13:15 PDT 2014


Author: rsmith
Date: Tue Aug 12 21:13:15 2014
New Revision: 215520

URL: http://llvm.org/viewvc/llvm-project?rev=215520&view=rev
Log:
PR20634: add some more cases that can legitimately come after a struct declaration to our list of special cases.

Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/Parser/atomic.c
    cfe/trunk/test/Parser/cxx0x-decl.cpp
    cfe/trunk/test/Parser/declarators.c

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=215520&r1=215519&r2=215520&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Aug 12 21:13:15 2014
@@ -1066,6 +1066,8 @@ bool Parser::isValidAfterTypeSpecifier(b
   case tok::comma:              // __builtin_offsetof(struct foo{...} ,
   case tok::kw_operator:        // struct foo       operator  ++() {...}
   case tok::kw___declspec:      // struct foo {...} __declspec(...)
+  case tok::l_square:           // void f(struct f  [         3])
+  case tok::ellipsis:           // void f(struct f  ...       [Ns])
     return true;
   case tok::colon:
     return CouldBeBitfield;     // enum E { ... }   :         2;
@@ -1073,6 +1075,7 @@ bool Parser::isValidAfterTypeSpecifier(b
   case tok::kw_const:           // struct foo {...} const     x;
   case tok::kw_volatile:        // struct foo {...} volatile  x;
   case tok::kw_restrict:        // struct foo {...} restrict  x;
+  case tok::kw__Atomic:         // struct foo {...} _Atomic   x;
   // Function specifiers
   // Note, no 'explicit'. An explicit function must be either a conversion
   // operator or a constructor. Either way, it can't have a return type.
@@ -1111,10 +1114,6 @@ bool Parser::isValidAfterTypeSpecifier(b
     if (!getLangOpts().CPlusPlus)
       return true;
     break;
-    // C++11 attributes
-  case tok::l_square: // enum E [[]] x
-    // Note, no tok::kw_alignas here; alignas cannot appertain to a type.
-    return getLangOpts().CPlusPlus11 && NextToken().is(tok::l_square);
   case tok::greater:
     // template<class T = class X>
     return getLangOpts().CPlusPlus;
@@ -1669,7 +1668,11 @@ void Parser::ParseClassSpecifier(tok::To
   // Also enforce C++ [temp]p3:
   //   In a template-declaration which defines a class, no declarator
   //   is permitted.
+  //
+  // After a type-specifier, we don't expect a semicolon. This only happens in
+  // C, since definitions are not permitted in this context in C++.
   if (TUK == Sema::TUK_Definition &&
+      (getLangOpts().CPlusPlus || !isTypeSpecifier(DSC)) &&
       (TemplateInfo.Kind || !isValidAfterTypeSpecifier(false))) {
     if (Tok.isNot(tok::semi)) {
       const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();

Modified: cfe/trunk/test/Parser/atomic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/atomic.c?rev=215520&r1=215519&r2=215520&view=diff
==============================================================================
--- cfe/trunk/test/Parser/atomic.c (original)
+++ cfe/trunk/test/Parser/atomic.c Tue Aug 12 21:13:15 2014
@@ -33,3 +33,6 @@ typedef _Atomic(int) __attribute__((addr
 
 typedef _Atomic int __attribute__((vector_size(16))) atomic_vector_int;
 typedef _Atomic(int __attribute__((vector_size(16)))) atomic_vector_int;
+
+struct S
+_Atomic atomic_s_no_missing_semicolon;

Modified: cfe/trunk/test/Parser/cxx0x-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-decl.cpp?rev=215520&r1=215519&r2=215520&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-decl.cpp Tue Aug 12 21:13:15 2014
@@ -122,3 +122,8 @@ struct MemberComponentOrder : Base {
   void g() __attribute__(( )) override;
   void h() __attribute__(( )) override {}
 };
+
+void NoMissingSemicolonHere(struct S
+                            [3]);
+template<int ...N> void NoMissingSemicolonHereEither(struct S
+                                                     ... [N]);

Modified: cfe/trunk/test/Parser/declarators.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/declarators.c?rev=215520&r1=215519&r2=215520&view=diff
==============================================================================
--- cfe/trunk/test/Parser/declarators.c (original)
+++ cfe/trunk/test/Parser/declarators.c Tue Aug 12 21:13:15 2014
@@ -150,3 +150,5 @@ enum E16 {
   A6;  // expected-error{{expected '= constant-expression' or end of enumerator definition}}
   A6a
 };
+
+int PR20634 = sizeof(struct { int n; } [5]);





More information about the cfe-commits mailing list