From: Richard Smith Date: Tue, 23 Oct 2012 19:56:01 +0000 (+0000) Subject: When rebuilding a DependentScopeDeclRefExpr, perform a lookup into the scope X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=713c287caf70922f93cfd9292540bad274c4a82f;p=clang When rebuilding a DependentScopeDeclRefExpr, perform a lookup into the scope even if it's dependent, in case it now names a member of the current instantiation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166496 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 838d33150f..109386db6b 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1897,8 +1897,8 @@ ExprResult Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand) { - DeclContext *DC; - if (!(DC = computeDeclContext(SS, false)) || DC->isDependentContext()) + DeclContext *DC = computeDeclContext(SS, false); + if (!DC) return BuildDependentDeclRefExpr(SS, /*TemplateKWLoc=*/SourceLocation(), NameInfo, /*TemplateArgs=*/0); @@ -1911,6 +1911,10 @@ Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, if (R.isAmbiguous()) return ExprError(); + if (R.getResultKind() == LookupResult::NotFoundInCurrentInstantiation) + return BuildDependentDeclRefExpr(SS, /*TemplateKWLoc=*/SourceLocation(), + NameInfo, /*TemplateArgs=*/0); + if (R.empty()) { Diag(NameInfo.getLoc(), diag::err_no_member) << NameInfo.getName() << DC << SS.getRange(); diff --git a/test/SemaTemplate/current-instantiation.cpp b/test/SemaTemplate/current-instantiation.cpp index ccef811e22..f47c07187c 100644 --- a/test/SemaTemplate/current-instantiation.cpp +++ b/test/SemaTemplate/current-instantiation.cpp @@ -2,7 +2,7 @@ // This test concerns the identity of dependent types within the // canonical type system, specifically focusing on the difference -// between members of the current instantiation and membmers of an +// between members of the current instantiation and members of an // unknown specialization. This considers C++ [temp.type], which // specifies type equivalence within a template, and C++0x // [temp.dep.type], which defines what it means to be a member of the @@ -235,3 +235,15 @@ namespace rdar10194295 { template::Enum> class X::Inner { }; } + +namespace RebuildDependentScopeDeclRefExpr { + template struct N {}; + template struct X { + static const int thing = 0; + N data(); + N foo(); + }; + template N::thing> X::data() {} + // FIXME: We should issue a typo-correction here. + template N::think> X::foo() {} // expected-error {{no member named 'think' in 'X'}} +}