]> granicus.if.org Git - clang/commitdiff
mark the declspec as invalid when we recover instead of forcing to int,
authorChris Lattner <sabre@nondot.org>
Sun, 12 Apr 2009 22:12:26 +0000 (22:12 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 12 Apr 2009 22:12:26 +0000 (22:12 +0000)
this allows downstream diags to be properly silenced.

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

lib/Parse/ParseDecl.cpp
test/Parser/declarators.c

index ae00ada3110d0c2d6b4d7062f175ce2ec52d144d..5b8963f892c2b16e24750c385ec7d6d7d2d0c548 100644 (file)
@@ -681,9 +681,10 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
         }
         
         // Since this is almost certainly an invalid type name, emit a
-        // diagnostic that says it, eat the token, and pretend we saw an 'int'.
+        // diagnostic that says it, eat the token, and mark the declspec as
+        // invalid.
         Diag(Loc, diag::err_unknown_typename) << Tok.getIdentifierInfo();
-        DS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec);
+        DS.SetTypeSpecType(DeclSpec::TST_error, Loc, PrevSpec);
         DS.SetRangeEnd(Tok.getLocation());
         ConsumeToken();
         
@@ -691,7 +692,6 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
         // avoid rippling error messages on subsequent uses of the same type,
         // could be useful if #include was forgotten.
         
-        // FIXME: Mark DeclSpec as invalid.
         goto DoneWithDeclSpec;
       }
 
index 0b3f5cecd5073e1c7c6cce26cbeb85c881b6b3a2..d8cd5b6586c05b7bd76ad54b9cf389b6a870338c 100644 (file)
@@ -12,7 +12,7 @@ char ((((*X))));
 
 void (*signal(int, void (*)(int)))(int);
 
-int a, ***C, * const D, B(int);
+int aaaa, ***C, * const D, B(int);
 
 int *A;
 
@@ -41,7 +41,7 @@ int (test5), ;  // expected-error {{expected identifier or '('}}
 // PR3963 & rdar://6759604 - test error recovery for mistyped "typenames".
 
 foo_t *d;      // expected-error {{unknown type name 'foo_t'}}
-foo_t a = 4;   // expected-error {{unknown type name 'foo_t'}}
+foo_t a;   // expected-error {{unknown type name 'foo_t'}}
 int test6() { return a; }  // a should be declared.
 
 // Use of tagged type without tag. rdar://6783347
@@ -56,6 +56,8 @@ float *test7() {
   return &b.y;   // expected-warning {{incompatible pointer types returning 'int *', expected 'float *'}}
 }
 
+struct xyz test8() { return a; }  // a should be be marked invalid, no diag.
+
 
 // Verify that implicit int still works.
 static f;      // expected-warning {{type specifier missing, defaults to 'int'}}