mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +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
|
@ -2452,6 +2452,26 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
public void testDelegatingConstructorCallInConstexprConstructor_509871() throws Exception {
|
||||
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 };
|
||||
// const NoneType None = None;
|
||||
|
|
|
@ -331,16 +331,18 @@ public final class EvalConstructor extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||
IType newType = CPPTemplates.instantiateType(fType, context);
|
||||
|
||||
ICPPEvaluation[] newArguments = new ICPPEvaluation[fArguments.length];
|
||||
for (int i = 0; i < fArguments.length; i++) {
|
||||
newArguments[i] = fArguments[i].instantiate(context, maxDepth);
|
||||
}
|
||||
|
||||
IType newType = null;
|
||||
ICPPConstructor newConstructor;
|
||||
try {
|
||||
newConstructor = (ICPPConstructor) CPPTemplates.instantiateBinding(fConstructor, context, maxDepth);
|
||||
if (newConstructor != null) {
|
||||
newType = newConstructor.getClassOwner();
|
||||
}
|
||||
if (newConstructor instanceof CPPDeferredFunction) {
|
||||
ICPPFunction[] candidates = ((CPPDeferredFunction) newConstructor).getCandidates();
|
||||
if (candidates != null) {
|
||||
|
@ -352,6 +354,9 @@ public final class EvalConstructor extends CPPDependentEvaluation {
|
|||
if (resolved instanceof EvalBinding) {
|
||||
EvalBinding evalBinding = (EvalBinding) resolved;
|
||||
newConstructor = (ICPPConstructor) evalBinding.getBinding();
|
||||
if (newConstructor != null) {
|
||||
newType = newConstructor.getClassOwner();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -359,6 +364,15 @@ public final class EvalConstructor extends CPPDependentEvaluation {
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue