From a6d1e7623a9b7bd60779275c42827951a892993b Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 10 Aug 2011 21:59:45 +0000 Subject: [PATCH] When performing the lookup in the current scope for a member access to a member template, e.g., x.f if we have found a template in the type of x, but the lookup in the current scope is ambiguous, just ignore the lookup in the current scope. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137255 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplate.cpp | 4 +++- .../basic.lookup/basic.lookup.classref/p1.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index e960452e06..ded352047a 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -344,10 +344,12 @@ void Sema::LookupTemplateName(LookupResult &Found, if (FoundOuter.empty()) { // - if the name is not found, the name found in the class of the // object expression is used, otherwise - } else if (!FoundOuter.getAsSingle()) { + } else if (!FoundOuter.getAsSingle() || + FoundOuter.isAmbiguous()) { // - if the name is found in the context of the entire // postfix-expression and does not name a class template, the name // found in the class of the object expression is used, otherwise + FoundOuter.clear(); } else if (!Found.isSuppressingDiagnostics()) { // - if the name found is a class template, it must refer to the same // entity as the one found in the class of the object expression, diff --git a/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp b/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp index 3fde0daa96..c35af1def2 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp @@ -44,3 +44,21 @@ void resolves_to_different() { v.set(3.2); } } + +namespace rdar9915664 { + struct A { + template void a(); + }; + + struct B : A { }; + + struct C : A { }; + + struct D : B, C { + A &getA() { return static_cast(*this); } + + void test_a() { + getA().a(); + } + }; +} -- 2.40.0