]> granicus.if.org Git - clang/commitdiff
Make sure we clear TypeSpecOwned when setting TypeSpecType to something when
authorJohn McCall <rjmccall@apple.com>
Thu, 26 Aug 2010 17:22:34 +0000 (17:22 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 26 Aug 2010 17:22:34 +0000 (17:22 +0000)
it might previously have been a tag TST.

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

lib/Sema/DeclSpec.cpp
test/Parser/declarators.c

index 956775aa63a4c282f4a0102c1a794928c661a4d4..b46e8af9db868095111773cbce877241809a70fa 100644 (file)
@@ -396,6 +396,7 @@ bool DeclSpec::SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
 
 bool DeclSpec::SetTypeSpecError() {
   TypeSpecType = TST_error;
+  TypeSpecOwned = false;
   TSTLoc = SourceLocation();
   return false;
 }
@@ -544,6 +545,7 @@ void DeclSpec::Finish(Diagnostic &D, Preprocessor &PP) {
       TypeSpecType = TST_int;
       TypeSpecSign = TSS_unsigned;
       TypeSpecWidth = TSW_short;
+      TypeSpecOwned = false;
     }
   }
 
@@ -573,6 +575,7 @@ void DeclSpec::Finish(Diagnostic &D, Preprocessor &PP) {
                                       : diag::err_invalid_longlong_spec)
         <<  getSpecifierName((TST)TypeSpecType);
       TypeSpecType = TST_int;
+      TypeSpecOwned = false;
     }
     break;
   case TSW_long:  // long double, long int
@@ -582,6 +585,7 @@ void DeclSpec::Finish(Diagnostic &D, Preprocessor &PP) {
       Diag(D, TSWLoc, SrcMgr, diag::err_invalid_long_spec)
         << getSpecifierName((TST)TypeSpecType);
       TypeSpecType = TST_int;
+      TypeSpecOwned = false;
     }
     break;
   }
@@ -622,6 +626,8 @@ void DeclSpec::Finish(Diagnostic &D, Preprocessor &PP) {
     ClearStorageClassSpecs();
   }
 
+  assert(!TypeSpecOwned || isDeclRep((TST) TypeSpecType));
+
   // Okay, now we can infer the real type.
 
   // TODO: return "auto function" and other bad things based on the real type.
index fb69fa9c1d05a71223eb0435ede09833e9f949cf..ac960cd263fef68f328ce9f9fb7fe242e00e8d0a 100644 (file)
@@ -94,3 +94,6 @@ void test14()  // expected-error {{expected ';' after top level declarator}}
 
 void test14a();
 void *test14b = (void*)test14a; // Make sure test14a didn't get skipped.
+
+// rdar://problem/8358508
+long struct X {} test15(); // expected-error {{'long struct' is invalid}}