Make Sema::ActOnCXXEnterDeclaratorScope robust against failures to compute
the declaration context, as occurs with out-of-line class template member
definitions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76622 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp
index a14bcd5..aad6e6d 100644
--- a/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/lib/Sema/SemaCXXScopeSpec.cpp
@@ -286,7 +286,10 @@
/// The 'SS' should be a non-empty valid CXXScopeSpec.
void Sema::ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS) {
assert(SS.isSet() && "Parser passed invalid CXXScopeSpec.");
- EnterDeclaratorContext(S, computeDeclContext(SS));
+ if (DeclContext *DC = computeDeclContext(SS))
+ EnterDeclaratorContext(S, DC);
+ else
+ const_cast<CXXScopeSpec&>(SS).setScopeRep(0);
}
/// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
@@ -296,6 +299,8 @@
/// defining scope.
void Sema::ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS) {
assert(SS.isSet() && "Parser passed invalid CXXScopeSpec.");
- assert(S->getEntity() == computeDeclContext(SS) && "Context imbalance!");
- ExitDeclaratorContext(S);
+ assert((SS.isInvalid() || S->getEntity() == computeDeclContext(SS)) &&
+ "Context imbalance!");
+ if (!SS.isInvalid())
+ ExitDeclaratorContext(S);
}