Fix a crash when parsing malformed out-of-line member function
definition. radar 8307865.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111163 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index b0d9da5..7149d4d 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -2727,7 +2727,10 @@
if (Actions.ShouldEnterDeclaratorScope(getCurScope(), D.getCXXScopeSpec()))
// Change the declaration context for name lookup, until this function
// is exited (and the declarator has been parsed).
- DeclScopeObj.EnterDeclaratorScope();
+ // If there was an error parsing parenthesized declarator, declarator
+ // scope may have been enterred before. Don't do it again.
+ if (!D.isInvalidType())
+ DeclScopeObj.EnterDeclaratorScope();
}
} else if (D.mayOmitIdentifier()) {
// This could be something simple like "int" (in which case the declarator
diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp
index e4c703c..e00ffd0 100644
--- a/test/Parser/cxx-decl.cpp
+++ b/test/Parser/cxx-decl.cpp
@@ -76,3 +76,10 @@
} // no ;
typedef Class1<Class2> Type1; // expected-error {{cannot combine with previous 'class' declaration specifier}}
+
+// rdar : // 8307865
+struct CodeCompleteConsumer {
+};
+
+void CodeCompleteConsumer::() { // expected-error {{xpected unqualified-id}}
+}