diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index fd297d587bd..b516029160d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -4167,4 +4167,20 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code, ParserLanguage.CPP); } + + // template class XT { + // void n() { + // m(); // ok + // } + // void m() const { + // n(); // must be a problem + // } + // }; + public void testResolutionOfNonDependentNames_293052() throws Exception { + final String code = getAboveComment(); + BindingAssertionHelper bh= new BindingAssertionHelper(code, true); + ICPPFunction func= bh.assertNonProblem("m();", 1, ICPPFunction.class); + assertFalse(func instanceof ICPPUnknownBinding); + bh.assertProblem("n();", 1); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 3110e135bcb..0b04ee9c13f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -2157,9 +2157,17 @@ public class CPPSemantics { } else if (thisType.isSameType(implicitType)) { cost = new Cost(thisType, implicitType, Rank.IDENTITY); } else { - if (CPPTemplates.isDependentType(implicitType)) - return CONTAINS_DEPENDENT_TYPES; cost = Conversions.checkImplicitConversionSequence(sourceIsLValue, thisType, implicitType, UDCMode.noUDC, true); + if (cost.getRank() == Rank.NO_MATCH) { + if (CPPTemplates.isDependentType(implicitType) || CPPTemplates.isDependentType(thisType)) { + IType s= getNestedType(thisType, TDEF|REF|CVQ); + IType t= getNestedType(implicitType, TDEF|REF|CVQ); + if (Conversions.calculateInheritanceDepth(MAX_INHERITANCE_DEPTH, s, t) >= 0) + return null; + + return CONTAINS_DEPENDENT_TYPES; + } + } } if (cost.getRank() == Rank.NO_MATCH) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java index 9f9f371ff0e..ef202c64ccf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java @@ -479,7 +479,7 @@ public class Conversions { * no inheritance relation * @throws DOMException */ - private static final int calculateInheritanceDepth(int maxdepth, IType type, IType ancestorToFind) + static final int calculateInheritanceDepth(int maxdepth, IType type, IType ancestorToFind) throws DOMException { if (type == ancestorToFind || type.isSameType(ancestorToFind)) { return 0;