diff options
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | test/Parser/cxx-undeclared-identifier.cpp | 2 | ||||
-rw-r--r-- | test/Parser/recovery.cpp | 7 |
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 341e8feba6..102a6ae9a2 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9299,7 +9299,9 @@ CreateNewDecl: AddPushedVisibilityAttribute(New); OwnedDecl = true; - return New; + // In C++, don't return an invalid declaration. We can't recover well from + // the cases where we make the type anonymous. + return (Invalid && getLangOpts().CPlusPlus) ? 0 : New; } void Sema::ActOnTagStartDefinition(Scope *S, Decl *TagD) { diff --git a/test/Parser/cxx-undeclared-identifier.cpp b/test/Parser/cxx-undeclared-identifier.cpp index 6ea2965913..a3f9e02794 100644 --- a/test/Parser/cxx-undeclared-identifier.cpp +++ b/test/Parser/cxx-undeclared-identifier.cpp @@ -16,6 +16,4 @@ namespace ImplicitInt { int f(a::b::c); // expected-error {{use of undeclared identifier 'a'}} class Foo::Bar { // expected-error {{use of undeclared identifier 'Foo'}} \ - // expected-note {{to match this '{'}} \ // expected-error {{expected ';' after class}} - // expected-error {{expected '}'}} diff --git a/test/Parser/recovery.cpp b/test/Parser/recovery.cpp index 732b9aee16..41845fb291 100644 --- a/test/Parser/recovery.cpp +++ b/test/Parser/recovery.cpp @@ -43,3 +43,10 @@ strcut Uuuu { // expected-error {{did you mean the keyword 'struct'}} \ // expected-note {{'Uuuu' declared here}} } *u[3]; uuuu v; // expected-error {{did you mean 'Uuuu'}} + +struct Redefined { // expected-note {{previous}} + Redefined() {} +}; +struct Redefined { // expected-error {{redefinition}} + Redefined() {} +}; |