mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 374993. Fixed AST2TemplateTests.testDependentExpressions_b.
This commit is contained in:
parent
b8b5c3e1b1
commit
8ced7ce43b
6 changed files with 25 additions and 17 deletions
|
@ -5661,7 +5661,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// void test(B<int>::pointer a) {
|
// void test(B<int>::pointer a) {
|
||||||
// f(a);
|
// f(a);
|
||||||
// }
|
// }
|
||||||
public void _testDependentExpressions_b() throws Exception {
|
public void testDependentExpressions_b() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
||||||
ICPPFunction func= bh.assertNonProblem("f(a)", 1, ICPPFunction.class);
|
ICPPFunction func= bh.assertNonProblem("f(a)", 1, ICPPFunction.class);
|
||||||
|
|
|
@ -215,6 +215,9 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CPPEvaluation() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getSignature() {
|
public char[] getSignature() {
|
||||||
SignatureBuilder buf = new SignatureBuilder();
|
SignatureBuilder buf = new SignatureBuilder();
|
||||||
|
|
|
@ -1259,6 +1259,13 @@ public class CPPTemplates {
|
||||||
return typeContainer;
|
return typeContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type instanceof TypeOfDependentExpression) {
|
||||||
|
ICPPEvaluation eval = ((TypeOfDependentExpression) type).getEvaluation();
|
||||||
|
ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point);
|
||||||
|
if (instantiated != eval)
|
||||||
|
return instantiated.getTypeOrFunctionSet(point);
|
||||||
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return e.getProblem();
|
return e.getProblem();
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
final IFunctionType type = ((IFunction) fBinding).getType();
|
final IFunctionType type = ((IFunction) fBinding).getType();
|
||||||
if (CPPTemplates.isDependentType(type))
|
if (CPPTemplates.isDependentType(type))
|
||||||
return new TypeOfDependentExpression(this);
|
return new TypeOfDependentExpression(this);
|
||||||
return SemanticUtil.mapToAST(type, point);
|
return SemanticUtil.mapToAST(type, point);
|
||||||
}
|
}
|
||||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -201,6 +202,7 @@ public class EvalFunctionCall extends CPPEvaluation {
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
if (args[0] instanceof EvalFunctionSet) {
|
if (args[0] instanceof EvalFunctionSet) {
|
||||||
|
// Resolve the function using the parameters of the function call.
|
||||||
CPPFunctionSet functionSet = ((EvalFunctionSet) args[0]).getFunctionSet();
|
CPPFunctionSet functionSet = ((EvalFunctionSet) args[0]).getFunctionSet();
|
||||||
ICPPFunction[] functions = functionSet.getBindings();
|
ICPPFunction[] functions = functionSet.getBindings();
|
||||||
LookupData data = new LookupData(functions[0].getNameCharArray(),
|
LookupData data = new LookupData(functions[0].getNameCharArray(),
|
||||||
|
@ -208,8 +210,8 @@ public class EvalFunctionCall extends CPPEvaluation {
|
||||||
data.setFunctionArguments(false, Arrays.copyOfRange(args, 1, args.length));
|
data.setFunctionArguments(false, Arrays.copyOfRange(args, 1, args.length));
|
||||||
try {
|
try {
|
||||||
IBinding binding = CPPSemantics.resolveFunction(data, functions, true);
|
IBinding binding = CPPSemantics.resolveFunction(data, functions, true);
|
||||||
if (binding instanceof ICPPFunction)
|
if (binding instanceof ICPPFunction && !(binding instanceof ICPPUnknownBinding))
|
||||||
return new EvalBinding(binding, null);
|
args[0] = new EvalBinding(binding, null);
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
|
@ -291,26 +290,23 @@ public class EvalID extends CPPEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
IBinding nameOwner = fNameOwner;
|
IBinding nameOwner = fNameOwner;
|
||||||
if (nameOwner instanceof ICPPTemplateParameter) {
|
if (nameOwner instanceof ICPPClassTemplate) {
|
||||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateParameter) nameOwner);
|
// TODO(sprigogin): Figure out why testDependentExpressions_a fails without special-casing ICPPClassTemplate
|
||||||
if (argument != null) {
|
|
||||||
IType type = argument.getTypeValue();
|
|
||||||
if (type instanceof IBinding)
|
|
||||||
nameOwner = (IBinding) type;
|
|
||||||
}
|
|
||||||
} else if (nameOwner instanceof ICPPUnknownBinding) {
|
|
||||||
nameOwner = resolveUnknown((ICPPUnknownBinding) nameOwner, tpMap, packOffset, within, point);
|
|
||||||
} else if (nameOwner instanceof ICPPClassTemplate) {
|
|
||||||
nameOwner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) nameOwner),
|
nameOwner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) nameOwner),
|
||||||
tpMap, packOffset, within, point);
|
tpMap, packOffset, within, point);
|
||||||
|
} else if (nameOwner instanceof IType) {
|
||||||
|
IType type = CPPTemplates.instantiateType((IType) nameOwner, tpMap, packOffset, within, point);
|
||||||
|
if (type instanceof IBinding)
|
||||||
|
nameOwner = (IBinding) type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldOwner instanceof IProblemBinding || nameOwner instanceof IProblemBinding)
|
if (fieldOwner instanceof IProblemBinding || nameOwner instanceof IProblemBinding)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
if (Arrays.equals(templateArgs, fTemplateArgs) && fieldOwner == fFieldOwner && nameOwner == fNameOwner)
|
if (Arrays.equals(templateArgs, fTemplateArgs) && fieldOwner == fFieldOwner && nameOwner == fNameOwner)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
ICPPEvaluation eval = resolveName((ICPPClassType) nameOwner, fTemplateArgs, point);
|
ICPPEvaluation eval = resolveName((ICPPClassType) nameOwner, templateArgs, point);
|
||||||
if (eval != null)
|
if (eval != null)
|
||||||
return eval;
|
return eval;
|
||||||
|
|
||||||
|
@ -329,7 +325,7 @@ public class EvalID extends CPPEvaluation {
|
||||||
if (bindings.length > 1 && bindings[0] instanceof ICPPFunction) {
|
if (bindings.length > 1 && bindings[0] instanceof ICPPFunction) {
|
||||||
ICPPFunction[] functions = new ICPPFunction[bindings.length];
|
ICPPFunction[] functions = new ICPPFunction[bindings.length];
|
||||||
System.arraycopy(bindings, 0, functions, 0, bindings.length);
|
System.arraycopy(bindings, 0, functions, 0, bindings.length);
|
||||||
return new EvalFunctionSet(new CPPFunctionSet(functions, fTemplateArgs, null), fAddressOf);
|
return new EvalFunctionSet(new CPPFunctionSet(functions, templateArgs, null), fAddressOf);
|
||||||
}
|
}
|
||||||
IBinding binding = bindings.length == 1 ? bindings[0] : null;
|
IBinding binding = bindings.length == 1 ? bindings[0] : null;
|
||||||
if (binding instanceof IEnumerator) {
|
if (binding instanceof IEnumerator) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue