1
0
Fork 0
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:
Sergey Prigogin 2012-08-06 21:14:00 -07:00
parent b8b5c3e1b1
commit 8ced7ce43b
6 changed files with 25 additions and 17 deletions

View file

@ -5661,7 +5661,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// void test(B<int>::pointer a) {
// f(a);
// }
public void _testDependentExpressions_b() throws Exception {
public void testDependentExpressions_b() throws Exception {
parseAndCheckBindings();
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
ICPPFunction func= bh.assertNonProblem("f(a)", 1, ICPPFunction.class);

View file

@ -215,6 +215,9 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
}
}
CPPEvaluation() {
}
@Override
public char[] getSignature() {
SignatureBuilder buf = new SignatureBuilder();

View file

@ -1259,6 +1259,13 @@ public class CPPTemplates {
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;
} catch (DOMException e) {
return e.getProblem();

View file

@ -160,7 +160,7 @@ public class EvalBinding extends CPPEvaluation {
final IFunctionType type = ((IFunction) fBinding).getType();
if (CPPTemplates.isDependentType(type))
return new TypeOfDependentExpression(this);
return SemanticUtil.mapToAST(type, point);
return SemanticUtil.mapToAST(type, point);
}
return ProblemType.UNKNOWN_FOR_EXPRESSION;
}

View file

@ -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.cpp.CPPFunction;
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.semantics.CPPSemantics.LookupMode;
import org.eclipse.core.runtime.CoreException;
@ -201,6 +202,7 @@ public class EvalFunctionCall extends CPPEvaluation {
return this;
if (args[0] instanceof EvalFunctionSet) {
// Resolve the function using the parameters of the function call.
CPPFunctionSet functionSet = ((EvalFunctionSet) args[0]).getFunctionSet();
ICPPFunction[] functions = functionSet.getBindings();
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));
try {
IBinding binding = CPPSemantics.resolveFunction(data, functions, true);
if (binding instanceof ICPPFunction)
return new EvalBinding(binding, null);
if (binding instanceof ICPPFunction && !(binding instanceof ICPPUnknownBinding))
args[0] = new EvalBinding(binding, null);
} catch (DOMException e) {
CCorePlugin.log(e);
}

View file

@ -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.ICPPTemplateArgument;
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.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
@ -291,26 +290,23 @@ public class EvalID extends CPPEvaluation {
}
IBinding nameOwner = fNameOwner;
if (nameOwner instanceof ICPPTemplateParameter) {
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateParameter) nameOwner);
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) {
if (nameOwner instanceof ICPPClassTemplate) {
// TODO(sprigogin): Figure out why testDependentExpressions_a fails without special-casing ICPPClassTemplate
nameOwner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) nameOwner),
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)
return this;
if (Arrays.equals(templateArgs, fTemplateArgs) && fieldOwner == fFieldOwner && nameOwner == fNameOwner)
return this;
ICPPEvaluation eval = resolveName((ICPPClassType) nameOwner, fTemplateArgs, point);
ICPPEvaluation eval = resolveName((ICPPClassType) nameOwner, templateArgs, point);
if (eval != null)
return eval;
@ -329,7 +325,7 @@ public class EvalID extends CPPEvaluation {
if (bindings.length > 1 && bindings[0] instanceof ICPPFunction) {
ICPPFunction[] functions = new ICPPFunction[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;
if (binding instanceof IEnumerator) {