mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 08:45:44 +02:00
Revert "Bug 401743 - NullPointerException in EvalBinding.instantiate() - tpMap is null"
This reverts commit 773aa77a2a
.
This commit is contained in:
parent
0de53f5f2a
commit
52c0edd492
4 changed files with 6 additions and 48 deletions
|
@ -7351,29 +7351,4 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
public void testVariadicNonTypeTemplateParameter_401400() throws Exception {
|
public void testVariadicNonTypeTemplateParameter_401400() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
// template <int...> struct tuple_indices {};
|
|
||||||
// template <int Sp, class IntTuple, int Ep>
|
|
||||||
// struct make_indices_imp;
|
|
||||||
// template <int Sp, int ...Indices, int Ep>
|
|
||||||
// struct make_indices_imp<Sp, tuple_indices<Indices...>, Ep> {
|
|
||||||
// typedef typename make_indices_imp<Sp + 1, tuple_indices<Indices..., Sp>, Ep>::type type;
|
|
||||||
// };
|
|
||||||
// template <int Ep, int ...Indices>
|
|
||||||
// struct make_indices_imp<Ep, tuple_indices<Indices...>, Ep> {
|
|
||||||
// typedef tuple_indices<Indices...> type;
|
|
||||||
// };
|
|
||||||
// template <int Ep, int Sp = 0>
|
|
||||||
// struct make_tuple_indices {
|
|
||||||
// typedef typename make_indices_imp<Sp, tuple_indices<>, Ep>::type type;
|
|
||||||
// };
|
|
||||||
// template <class ... Args>
|
|
||||||
// class async_func {
|
|
||||||
// void operator()() {
|
|
||||||
// typedef typename make_tuple_indices<1 + sizeof...(Args), 1>::type Index;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
public void testVariadicTemplatesNPE_401743() throws Exception {
|
|
||||||
parseAndCheckBindings();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,18 +402,6 @@ public class Value implements IValue {
|
||||||
public static boolean isDependentValue(IValue nonTypeValue) {
|
public static boolean isDependentValue(IValue nonTypeValue) {
|
||||||
if (nonTypeValue == null)
|
if (nonTypeValue == null)
|
||||||
return false;
|
return false;
|
||||||
// Unknown values may or may not be dependent. In the case of a template with
|
|
||||||
// a non-type template argument, whether or not the argument's value is dependent
|
|
||||||
// determines whether or not the template gets instantiated. In light of this,
|
|
||||||
// it's safer to assume that an unknown value is dependent because:
|
|
||||||
// 1. Instantiating a template with a non-type template argument whose value is
|
|
||||||
// unknown is useless.
|
|
||||||
// 2. Instantiating such a template can lead to an infinite recursion of
|
|
||||||
// instantiations (e.g. consider a template A<N> that delegates to A<N - 1>,
|
|
||||||
// with A<0> being specialized to end the recursion - if N is unknown,
|
|
||||||
// N - 1 will be unknown as well, and we get an infinite recursion).
|
|
||||||
if (nonTypeValue == UNKNOWN)
|
|
||||||
return true;
|
|
||||||
ICPPEvaluation eval = nonTypeValue.getEvaluation();
|
ICPPEvaluation eval = nonTypeValue.getEvaluation();
|
||||||
return eval != null && eval.isValueDependent();
|
return eval != null && eval.isValueDependent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,11 +279,6 @@ public class EvalBinding extends CPPDependentEvaluation {
|
||||||
value= ((IVariable) fBinding).getInitialValue();
|
value= ((IVariable) fBinding).getInitialValue();
|
||||||
} else if (fBinding instanceof IEnumerator) {
|
} else if (fBinding instanceof IEnumerator) {
|
||||||
value= ((IEnumerator) fBinding).getValue();
|
value= ((IEnumerator) fBinding).getValue();
|
||||||
} else if (fBinding instanceof IFunction) {
|
|
||||||
// If a function passed as a non-type template parameter is constexpr,
|
|
||||||
// it can be used inside the template as a constexpr function, so it's
|
|
||||||
// important to preserve the binding in the value.
|
|
||||||
value = Value.create(this);
|
|
||||||
}
|
}
|
||||||
if (value == null)
|
if (value == null)
|
||||||
value = Value.UNKNOWN;
|
value = Value.UNKNOWN;
|
||||||
|
@ -341,11 +336,9 @@ public class EvalBinding extends CPPDependentEvaluation {
|
||||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||||
IBinding origBinding = getBinding();
|
IBinding origBinding = getBinding();
|
||||||
if (origBinding instanceof ICPPTemplateNonTypeParameter) {
|
if (origBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||||
if (tpMap != null) {
|
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding, packOffset);
|
||||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding, packOffset);
|
if (argument != null && argument.isNonTypeValue()) {
|
||||||
if (argument != null && argument.isNonTypeValue()) {
|
return argument.getNonTypeEvaluation();
|
||||||
return argument.getNonTypeEvaluation();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (origBinding instanceof ICPPParameter) {
|
} else if (origBinding instanceof ICPPParameter) {
|
||||||
ICPPParameter parameter = (ICPPParameter) origBinding;
|
ICPPParameter parameter = (ICPPParameter) origBinding;
|
||||||
|
|
|
@ -354,8 +354,10 @@ public class EvalID extends CPPDependentEvaluation {
|
||||||
return new EvalFunctionSet(new CPPFunctionSet(functions, templateArgs, null), fAddressOf, getTemplateDefinition());
|
return new EvalFunctionSet(new CPPFunctionSet(functions, templateArgs, null), fAddressOf, getTemplateDefinition());
|
||||||
}
|
}
|
||||||
IBinding binding = bindings.length == 1 ? bindings[0] : null;
|
IBinding binding = bindings.length == 1 ? bindings[0] : null;
|
||||||
if (binding instanceof IEnumerator || binding instanceof ICPPMember) {
|
if (binding instanceof IEnumerator) {
|
||||||
return new EvalBinding(binding, null, getTemplateDefinition());
|
return new EvalBinding(binding, null, getTemplateDefinition());
|
||||||
|
} else if (binding instanceof ICPPMember) {
|
||||||
|
return new EvalMemberAccess(nameOwner, ValueCategory.PRVALUE, binding, false, getTemplateDefinition());
|
||||||
} else if (binding instanceof CPPFunctionSet) {
|
} else if (binding instanceof CPPFunctionSet) {
|
||||||
return new EvalFunctionSet((CPPFunctionSet) binding, fAddressOf, getTemplateDefinition());
|
return new EvalFunctionSet((CPPFunctionSet) binding, fAddressOf, getTemplateDefinition());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue