]> granicus.if.org Git - clang/commitdiff
the declspec of a declaration can have storage-class specifiers,
authorChris Lattner <sabre@nondot.org>
Tue, 2 Feb 2010 17:32:27 +0000 (17:32 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 2 Feb 2010 17:32:27 +0000 (17:32 +0000)
type qualifiers and type specifiers in any order.   For example,
this is valid: struct x {...} typedef y;

This fixes PR6208.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95094 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDeclCXX.cpp
test/Parser/declarators.c
test/Sema/declspec.c

index 234ec4c8b59c23b8621c4c73e8f570ae31fdc063..371aba1719944c78c69afacef59244ebabc5b8a4 100644 (file)
@@ -935,13 +935,24 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
   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 {...} } 
index 074e2ad7cb8817e531246ad9cd331c2dd8ac653f..edd68cc28c2514d776176b27483a5a4973a26395 100644 (file)
@@ -71,3 +71,7 @@ struct test9 {
   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;
index e1f2bf4911a6c6dc3aa9625b15be1766c6e6dd75..d9f4157ab3dbe402454042803736047088e146b0 100644 (file)
@@ -8,8 +8,11 @@ void foof(const char *, ...) __attribute__((__format__(__printf__, 1, 2))), barf
 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.