mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Overload resolution for non-dependent names, bug 293052.
This commit is contained in:
parent
247c59316f
commit
64781791db
3 changed files with 27 additions and 3 deletions
|
@ -4167,4 +4167,20 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
final String code= getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
}
|
||||
|
||||
// template<typename T> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue