[cfe-commits] r137255 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
Douglas Gregor
dgregor at apple.com
Wed Aug 10 14:59:45 PDT 2011
Author: dgregor
Date: Wed Aug 10 16:59:45 2011
New Revision: 137255
URL: http://llvm.org/viewvc/llvm-project?rev=137255&view=rev
Log:
When performing the lookup in the current scope for a member access to
a member template, e.g.,
x.f<int>
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 <rdar://problem/9915664>.
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=137255&r1=137254&r2=137255&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Aug 10 16:59:45 2011
@@ -344,10 +344,12 @@
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<ClassTemplateDecl>()) {
+ } else if (!FoundOuter.getAsSingle<ClassTemplateDecl>() ||
+ 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,
Modified: cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp?rev=137255&r1=137254&r2=137255&view=diff
==============================================================================
--- cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp (original)
+++ cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp Wed Aug 10 16:59:45 2011
@@ -44,3 +44,21 @@
v.set<double>(3.2);
}
}
+
+namespace rdar9915664 {
+ struct A {
+ template<typename T> void a();
+ };
+
+ struct B : A { };
+
+ struct C : A { };
+
+ struct D : B, C {
+ A &getA() { return static_cast<B&>(*this); }
+
+ void test_a() {
+ getA().a<int>();
+ }
+ };
+}
More information about the cfe-commits
mailing list