]> granicus.if.org Git - clang/commitdiff
Make Sema::ActOnCXXEnterDeclaratorScope robust against failures to compute
authorDouglas Gregor <dgregor@apple.com>
Tue, 21 Jul 2009 18:59:28 +0000 (18:59 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 21 Jul 2009 18:59:28 +0000 (18:59 +0000)
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

include/clang/Parse/Parser.h
lib/Sema/SemaCXXScopeSpec.cpp

index 18f61e793c23dc21a0d848735a00b1096ae2193b..bebc874b626232675b4657daac87318a5c1293f7 100644 (file)
@@ -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() {
index a14bcd5287cd595027975e4d92e67cce328b29bd..aad6e6d68c873e02b6185d446a77c72a7506af6d 100644 (file)
@@ -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);
 }