[cfe-commits] r95094 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp test/Parser/declarators.c test/Sema/declspec.c

Chris Lattner sabre at nondot.org
Tue Feb 2 09:32:27 PST 2010


Author: lattner
Date: Tue Feb  2 11:32:27 2010
New Revision: 95094

URL: http://llvm.org/viewvc/llvm-project?rev=95094&view=rev
Log:
the declspec of a declaration can have storage-class specifiers,
type qualifiers and type specifiers in any order.   For example,
this is valid: struct x {...} typedef y;

This fixes PR6208.

Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/Parser/declarators.c
    cfe/trunk/test/Sema/declspec.c

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=95094&r1=95093&r2=95094&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Feb  2 11:32:27 2010
@@ -935,13 +935,24 @@
   if (TUK == Action::TUK_Definition) {
     switch (Tok.getKind()) {
     case tok::semi:               // struct foo {...} ;
-    case tok::star:               // struct foo {...} *       P;
-    case tok::amp:                // struct foo {...} &       R = ...
-    case tok::identifier:         // struct foo {...} V       ;
-    case tok::r_paren:            //(struct foo {...} )       {4}
-    case tok::annot_cxxscope:     // struct foo {...} a::     b;
-    case tok::annot_typename:     // struct foo {...} a       ::b;
-    case tok::annot_template_id:  // struct foo {...} a<int>  ::b;
+    case tok::star:               // struct foo {...} *         P;
+    case tok::amp:                // struct foo {...} &         R = ...
+    case tok::identifier:         // struct foo {...} V         ;
+    case tok::r_paren:            //(struct foo {...} )         {4}
+    case tok::annot_cxxscope:     // struct foo {...} a::       b;
+    case tok::annot_typename:     // struct foo {...} a         ::b;
+    case tok::annot_template_id:  // struct foo {...} a<int>    ::b;
+    // Storage-class specifiers
+    case tok::kw_static:          // struct foo {...} static    x;
+    case tok::kw_extern:          // struct foo {...} extern    x;
+    case tok::kw_typedef:         // struct foo {...} typedef   x;
+    case tok::kw_register:        // struct foo {...} register  x;
+    case tok::kw_auto:            // struct foo {...} auto      x;
+    // Type qualifiers
+    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_inline:          // struct foo {...} inline    foo() {};
       break;
         
     case tok::r_brace:  // struct bar { struct foo {...} } 

Modified: cfe/trunk/test/Parser/declarators.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/declarators.c?rev=95094&r1=95093&r2=95094&view=diff

==============================================================================
--- cfe/trunk/test/Parser/declarators.c (original)
+++ cfe/trunk/test/Parser/declarators.c Tue Feb  2 11:32:27 2010
@@ -71,3 +71,7 @@
   int y;
   int z  // expected-warning {{expected ';' at end of declaration list}}
 };
+
+// PR6208
+struct test10 { int a; } static test10x;
+struct test11 { int a; } const test11x;

Modified: cfe/trunk/test/Sema/declspec.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/declspec.c?rev=95094&r1=95093&r2=95094&view=diff

==============================================================================
--- cfe/trunk/test/Sema/declspec.c (original)
+++ cfe/trunk/test/Sema/declspec.c Tue Feb  2 11:32:27 2010
@@ -8,8 +8,11 @@
 int typedef validTypeDecl() { } // expected-error {{function definition declared 'typedef'}}
 
 struct _zend_module_entry { }    // expected-error {{expected ';' after struct}}
+int gv1;
 typedef struct _zend_function_entry { } // expected-error {{expected ';' after struct}} \
                                         // expected-error {{declaration does not declare anything}}
+int gv2;
+
 static void buggy(int *x) { }
 
 // Type qualifiers.





More information about the cfe-commits mailing list