mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Bug 514595 - Instantiate EvalConstructor.fType correctly
Change-Id: I7ee2c7ffee4b15f0005ddb8bcc5c9051992908d3
This commit is contained in:
parent
8592b892dc
commit
e42a75e3e5
2 changed files with 36 additions and 2 deletions
|
@ -2453,6 +2453,26 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
checkBindings();
|
checkBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // empty file
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// struct base {
|
||||||
|
// constexpr base() : p(0) {}
|
||||||
|
// int p;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template <typename T>
|
||||||
|
// struct derived : public base<T> {
|
||||||
|
// constexpr derived() : base<T>() {}
|
||||||
|
// constexpr derived(int) : derived() {}
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// class C {};
|
||||||
|
// derived<C> waldo = 0;
|
||||||
|
public void testDelegatingConstructorCallInConstexprConstructor_514595() throws Exception {
|
||||||
|
checkBindings();
|
||||||
|
}
|
||||||
|
|
||||||
// enum class NoneType { None };
|
// enum class NoneType { None };
|
||||||
// const NoneType None = None;
|
// const NoneType None = None;
|
||||||
|
|
||||||
|
|
|
@ -331,16 +331,18 @@ public final class EvalConstructor extends CPPDependentEvaluation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
IType newType = CPPTemplates.instantiateType(fType, context);
|
|
||||||
|
|
||||||
ICPPEvaluation[] newArguments = new ICPPEvaluation[fArguments.length];
|
ICPPEvaluation[] newArguments = new ICPPEvaluation[fArguments.length];
|
||||||
for (int i = 0; i < fArguments.length; i++) {
|
for (int i = 0; i < fArguments.length; i++) {
|
||||||
newArguments[i] = fArguments[i].instantiate(context, maxDepth);
|
newArguments[i] = fArguments[i].instantiate(context, maxDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IType newType = null;
|
||||||
ICPPConstructor newConstructor;
|
ICPPConstructor newConstructor;
|
||||||
try {
|
try {
|
||||||
newConstructor = (ICPPConstructor) CPPTemplates.instantiateBinding(fConstructor, context, maxDepth);
|
newConstructor = (ICPPConstructor) CPPTemplates.instantiateBinding(fConstructor, context, maxDepth);
|
||||||
|
if (newConstructor != null) {
|
||||||
|
newType = newConstructor.getClassOwner();
|
||||||
|
}
|
||||||
if (newConstructor instanceof CPPDeferredFunction) {
|
if (newConstructor instanceof CPPDeferredFunction) {
|
||||||
ICPPFunction[] candidates = ((CPPDeferredFunction) newConstructor).getCandidates();
|
ICPPFunction[] candidates = ((CPPDeferredFunction) newConstructor).getCandidates();
|
||||||
if (candidates != null) {
|
if (candidates != null) {
|
||||||
|
@ -352,6 +354,9 @@ public final class EvalConstructor extends CPPDependentEvaluation {
|
||||||
if (resolved instanceof EvalBinding) {
|
if (resolved instanceof EvalBinding) {
|
||||||
EvalBinding evalBinding = (EvalBinding) resolved;
|
EvalBinding evalBinding = (EvalBinding) resolved;
|
||||||
newConstructor = (ICPPConstructor) evalBinding.getBinding();
|
newConstructor = (ICPPConstructor) evalBinding.getBinding();
|
||||||
|
if (newConstructor != null) {
|
||||||
|
newType = newConstructor.getClassOwner();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,6 +364,15 @@ public final class EvalConstructor extends CPPDependentEvaluation {
|
||||||
newConstructor = fConstructor;
|
newConstructor = fConstructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only instantiate fType separately if we couldn't get the instantiated type
|
||||||
|
// via newConstructor.getClassOwner() for some reason. This is not just for
|
||||||
|
// efficiency; instantiating fType directly will not work if fType is a
|
||||||
|
// CPPClassTemplate because CPPTemplates.instantiateType() does not instantiate
|
||||||
|
// CPPClassTemplates, only CPPDeferredClassInstances (TODO: why?).
|
||||||
|
if (newType == null) {
|
||||||
|
newType = CPPTemplates.instantiateType(fType, context);
|
||||||
|
}
|
||||||
|
|
||||||
return new EvalConstructor(newType, newConstructor, newArguments, getTemplateDefinition());
|
return new EvalConstructor(newType, newConstructor, newArguments, getTemplateDefinition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue