[cfe-commits] r68917 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/Parser/declarators.c
Chris Lattner
sabre at nondot.org
Sun Apr 12 15:12:26 PDT 2009
Author: lattner
Date: Sun Apr 12 17:12:26 2009
New Revision: 68917
URL: http://llvm.org/viewvc/llvm-project?rev=68917&view=rev
Log:
mark the declspec as invalid when we recover instead of forcing to int,
this allows downstream diags to be properly silenced.
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Parser/declarators.c
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=68917&r1=68916&r2=68917&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun Apr 12 17:12:26 2009
@@ -681,9 +681,10 @@
}
// 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 @@
// 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;
}
Modified: cfe/trunk/test/Parser/declarators.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/declarators.c?rev=68917&r1=68916&r2=68917&view=diff
==============================================================================
--- cfe/trunk/test/Parser/declarators.c (original)
+++ cfe/trunk/test/Parser/declarators.c Sun Apr 12 17:12:26 2009
@@ -12,7 +12,7 @@
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 @@
// 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 @@
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'}}
More information about the cfe-commits
mailing list