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.

llvm-svn: 169374
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 341e8fe..102a6ae 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -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) {
diff --git a/clang/test/Parser/cxx-undeclared-identifier.cpp b/clang/test/Parser/cxx-undeclared-identifier.cpp
index 6ea2965..a3f9e02 100644
--- a/clang/test/Parser/cxx-undeclared-identifier.cpp
+++ b/clang/test/Parser/cxx-undeclared-identifier.cpp
@@ -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 '}'}}
diff --git a/clang/test/Parser/recovery.cpp b/clang/test/Parser/recovery.cpp
index 732b9ae..41845fb 100644
--- a/clang/test/Parser/recovery.cpp
+++ b/clang/test/Parser/recovery.cpp
@@ -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() {}
+};