From 3ce7493c35d39138781d904814bc9ff0373ba8a3 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 5 Feb 2010 07:07:10 +0000 Subject: Teach C++ name lookup that it's okay to look in a scope without a context. This happens fairly rarely (which is why we got away with this bug). Fixes PR6184, where we skipped over the template parameter scope while tentatively parsing. llvm-svn: 95376 --- clang/lib/Sema/SemaLookup.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'clang/lib/Sema') diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index af1b8a276ef..3c8ab435a86 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -649,12 +649,9 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { for (; S; S = S->getParent()) { DeclContext *Ctx = static_cast(S->getEntity()); - if (!Ctx || Ctx->isTransparentContext()) + if (Ctx && Ctx->isTransparentContext()) continue; - assert(Ctx && Ctx->isFileContext() && - "We should have been looking only at file context here already."); - // Check whether the IdResolver has anything in this scope. bool Found = false; for (; I != IEnd && S->isDeclScope(DeclPtrTy::make(*I)); ++I) { @@ -668,16 +665,21 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { } } - // Look into context considering using-directives. - if (CppNamespaceLookup(R, Context, Ctx, UDirs)) - Found = true; + if (Ctx) { + assert(Ctx->isFileContext() && + "We should have been looking only at file context here already."); + + // Look into context considering using-directives. + if (CppNamespaceLookup(R, Context, Ctx, UDirs)) + Found = true; + } if (Found) { R.resolveKind(); return true; } - if (R.isForRedeclaration() && !Ctx->isTransparentContext()) + if (R.isForRedeclaration() && Ctx && !Ctx->isTransparentContext()) return false; } -- cgit v1.2.3