[cfe-commits] r169374 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Parser/cxx-undeclared-identifier.cpp test/Parser/recovery.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Wed Dec 5 03:34:07 PST 2012
Author: rsmith
Date: Wed Dec 5 05:34:06 2012
New Revision: 169374
URL: http://llvm.org/viewvc/llvm-project?rev=169374&view=rev
Log:
In C++, if we hit an error in the class-head, don't try to parse the class body.
Our error recovery path may have made the class anonymous, and that has a pretty
disastrous impact on any attempt to parse a class body containing constructors.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Parser/cxx-undeclared-identifier.cpp
cfe/trunk/test/Parser/recovery.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=169374&r1=169373&r2=169374&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Dec 5 05:34:06 2012
@@ -9299,7 +9299,9 @@
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) {
Modified: cfe/trunk/test/Parser/cxx-undeclared-identifier.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-undeclared-identifier.cpp?rev=169374&r1=169373&r2=169374&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-undeclared-identifier.cpp (original)
+++ cfe/trunk/test/Parser/cxx-undeclared-identifier.cpp Wed Dec 5 05:34:06 2012
@@ -16,6 +16,4 @@
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 '}'}}
Modified: cfe/trunk/test/Parser/recovery.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/recovery.cpp?rev=169374&r1=169373&r2=169374&view=diff
==============================================================================
--- cfe/trunk/test/Parser/recovery.cpp (original)
+++ cfe/trunk/test/Parser/recovery.cpp Wed Dec 5 05:34:06 2012
@@ -43,3 +43,10 @@
// 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() {}
+};
More information about the cfe-commits
mailing list