mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +02:00
Fix for bug 271948.
This commit is contained in:
parent
3e8db59e46
commit
395490c7ae
5 changed files with 20 additions and 16 deletions
|
@ -3994,7 +3994,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// void test(B p) {
|
// void test(B p) {
|
||||||
// f(p);
|
// f(p);
|
||||||
// }
|
// }
|
||||||
public void _testTemplateConversionOperator_271948_1() throws Exception {
|
public void testTemplateConversionOperator_271948_1() throws Exception {
|
||||||
final String code = getAboveComment();
|
final String code = getAboveComment();
|
||||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||||
}
|
}
|
||||||
|
@ -4009,12 +4009,12 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// operator A<T>();
|
// operator A<T>();
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// void f(A<char*> p);
|
// void f(const A<char*>& p);
|
||||||
//
|
//
|
||||||
// void test(B<int> p) {
|
// void test(B<int> x) {
|
||||||
// f(p);
|
// f(x);
|
||||||
// }
|
// }
|
||||||
public void _testTemplateConversionOperator_271948_2() throws Exception {
|
public void testTemplateConversionOperator_271948_2() throws Exception {
|
||||||
final String code = getAboveComment();
|
final String code = getAboveComment();
|
||||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
|
@ -27,7 +26,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
*/
|
*/
|
||||||
public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunction {
|
public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunction {
|
||||||
|
|
||||||
public static IFunction createForSample(IFunction sample, IASTName name) throws DOMException {
|
public static IFunction createForSample(IFunction sample) throws DOMException {
|
||||||
if (sample instanceof ICPPConstructor)
|
if (sample instanceof ICPPConstructor)
|
||||||
return new CPPUnknownConstructor(((ICPPConstructor) sample).getClassOwner());
|
return new CPPUnknownConstructor(((ICPPConstructor) sample).getClassOwner());
|
||||||
|
|
||||||
|
|
|
@ -2112,7 +2112,7 @@ public class CPPSemantics {
|
||||||
if (CPPTemplates.containsDependentType(argTypes)) {
|
if (CPPTemplates.containsDependentType(argTypes)) {
|
||||||
if (viableCount == 1)
|
if (viableCount == 1)
|
||||||
return firstViable;
|
return firstViable;
|
||||||
return CPPUnknownFunction.createForSample(firstViable, data.astName);
|
return CPPUnknownFunction.createForSample(firstViable);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean ambiguous = false; // ambiguity, 2 functions are equally good
|
boolean ambiguous = false; // ambiguity, 2 functions are equally good
|
||||||
|
@ -2131,7 +2131,7 @@ public class CPPSemantics {
|
||||||
if (fnCost == CONTAINS_DEPENDENT_TYPES) {
|
if (fnCost == CONTAINS_DEPENDENT_TYPES) {
|
||||||
if (viableCount == 1)
|
if (viableCount == 1)
|
||||||
return firstViable;
|
return firstViable;
|
||||||
return CPPUnknownFunction.createForSample(firstViable, data.astName);
|
return CPPUnknownFunction.createForSample(firstViable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fnCost.hasDeferredUDC()) {
|
if (fnCost.hasDeferredUDC()) {
|
||||||
|
@ -2272,7 +2272,7 @@ public class CPPSemantics {
|
||||||
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||||
}
|
}
|
||||||
if (!data.forFunctionDeclaration() || data.forExplicitFunctionSpecialization()) {
|
if (!data.forFunctionDeclaration() || data.forExplicitFunctionSpecialization()) {
|
||||||
CPPTemplates.instantiateConversionTemplates(fns, t, data.astName);
|
CPPTemplates.instantiateConversionTemplates(fns, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
IFunction unknown= null;
|
IFunction unknown= null;
|
||||||
|
|
|
@ -1361,13 +1361,13 @@ public class CPPTemplates {
|
||||||
templateArguments = ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
templateArguments = ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||||
try {
|
try {
|
||||||
if (containsDependentType(fnArgs)) {
|
if (containsDependentType(fnArgs)) {
|
||||||
functions[i]= CPPUnknownFunction.createForSample(template, name);
|
functions[i]= CPPUnknownFunction.createForSample(template);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (name instanceof ICPPASTTemplateId && !(template instanceof ICPPConstructor)) {
|
if (name instanceof ICPPASTTemplateId && !(template instanceof ICPPConstructor)) {
|
||||||
templateArguments = createTemplateArgumentArray((ICPPASTTemplateId) name);
|
templateArguments = createTemplateArgumentArray((ICPPASTTemplateId) name);
|
||||||
if (hasDependentArgument(templateArguments)) {
|
if (hasDependentArgument(templateArguments)) {
|
||||||
functions[i]= CPPUnknownFunction.createForSample(template, name);
|
functions[i]= CPPUnknownFunction.createForSample(template);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1396,6 +1396,10 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected void instantiateConversionTemplates(IFunction[] functions, IType conversionType, IASTName name) {
|
static protected void instantiateConversionTemplates(IFunction[] functions, IType conversionType, IASTName name) {
|
||||||
|
instantiateConversionTemplates(functions, conversionType);
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void instantiateConversionTemplates(IFunction[] functions, IType conversionType) {
|
||||||
boolean checkedForDependentType= false;
|
boolean checkedForDependentType= false;
|
||||||
for (int i = 0; i < functions.length; i++) {
|
for (int i = 0; i < functions.length; i++) {
|
||||||
IFunction func = functions[i];
|
IFunction func = functions[i];
|
||||||
|
@ -1407,7 +1411,7 @@ public class CPPTemplates {
|
||||||
if (!checkedForDependentType) {
|
if (!checkedForDependentType) {
|
||||||
try {
|
try {
|
||||||
if (isDependentType(conversionType)) {
|
if (isDependentType(conversionType)) {
|
||||||
functions[i]= CPPUnknownFunction.createForSample(template, name);
|
functions[i]= CPPUnknownFunction.createForSample(template);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
checkedForDependentType= true;
|
checkedForDependentType= true;
|
||||||
|
|
|
@ -369,8 +369,9 @@ public class Conversions {
|
||||||
boolean ambiguousConversionOperator= false;
|
boolean ambiguousConversionOperator= false;
|
||||||
if (s instanceof ICPPClassType) {
|
if (s instanceof ICPPClassType) {
|
||||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators((ICPPClassType) s);
|
ICPPMethod[] ops = SemanticUtil.getConversionOperators((ICPPClassType) s);
|
||||||
if (ops.length > 0 && !(ops[0] instanceof IProblemBinding)) {
|
CPPTemplates.instantiateConversionTemplates(ops, target);
|
||||||
for (final ICPPMethod op : ops) {
|
for (final ICPPMethod op : ops) {
|
||||||
|
if (op != null && !(op instanceof IProblemBinding)) {
|
||||||
Cost cost= checkStandardConversionSequence(op.getType().getReturnType(), target, false);
|
Cost cost= checkStandardConversionSequence(op.getType().getReturnType(), target, false);
|
||||||
if (cost.getRank() != Rank.NO_MATCH) {
|
if (cost.getRank() != Rank.NO_MATCH) {
|
||||||
int cmp= cost.compareTo(operatorCost);
|
int cmp= cost.compareTo(operatorCost);
|
||||||
|
|
Loading…
Add table
Reference in a new issue