diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-07-21 18:59:28 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-07-21 18:59:28 +0000 |
commit | 3fdbed594f4cb238fe37cad2ec3fefa3b6f67125 (patch) | |
tree | c5d871120dbfc5451b00b7d52dfbfbade5e01cc4 | |
parent | 006105d5a8c6565018e4e2a25860d4a7f4c7f4a6 (diff) |
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
-rw-r--r-- | include/clang/Parse/Parser.h | 3 | ||||
-rw-r--r-- | lib/Sema/SemaCXXScopeSpec.cpp | 11 |
2 files changed, 10 insertions, 4 deletions
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 18f61e793c..bebc874b62 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -1089,7 +1089,8 @@ private: assert(!EnteredScope && "Already entered the scope!"); assert(SS.isSet() && "C++ scope was not set!"); P.Actions.ActOnCXXEnterDeclaratorScope(P.CurScope, SS); - EnteredScope = true; + if (!SS.isInvalid()) + EnteredScope = true; } ~DeclaratorScopeObj() { diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index a14bcd5287..aad6e6d68c 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -286,7 +286,10 @@ Sema::CXXScopeTy *Sema::ActOnCXXNestedNameSpecifier(Scope *S, /// 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 @@ void Sema::ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS) { /// 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); } |