mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 540758 - Substitution of enclosing template parameters into expansion pattern
Change-Id: Ib31db579c7d5a9be2f64fe992abac48c0e2b136a
This commit is contained in:
parent
1a8b9a9628
commit
9e44f3634a
3 changed files with 41 additions and 3 deletions
|
@ -10703,6 +10703,33 @@ public class AST2TemplateTests extends AST2CPPTestBase {
|
|||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template<int Idx>
|
||||
// struct get_from_variadic_pack {
|
||||
// template<typename First, typename ... Accessors>
|
||||
// static constexpr int apply(First first, Accessors... args) {
|
||||
// return get_from_variadic_pack<Idx - 1>::apply(args...);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// template<>
|
||||
// struct get_from_variadic_pack<0> {
|
||||
// template<typename First, typename ... Accessors>
|
||||
// static constexpr int apply(First first, Accessors ... args) {
|
||||
// return first;
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// template<int N>
|
||||
// struct static_int{
|
||||
// static constexpr int value = N;
|
||||
// };
|
||||
//
|
||||
// constexpr int tmp = get_from_variadic_pack<1>::apply(1,2);
|
||||
// constexpr int result = static_int<tmp>::value;
|
||||
public void testInstantiationOfPackInNestedTemplate_540758() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// // A metafunction that loops infinitely on odd inputs.
|
||||
// template <int N>
|
||||
// struct meta {
|
||||
|
|
|
@ -124,7 +124,9 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
|
|||
if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
|
||||
newEval = EvalFixed.INCOMPLETE;
|
||||
} else if (packSize == CPPTemplates.PACK_SIZE_DEFER) {
|
||||
newEval = origEval;
|
||||
// We're not expanding the pack, but arguments for template parameters of
|
||||
// enclosing templates may still need to be substituted into the expansion pattern.
|
||||
newEval = origEval.instantiate(context, maxDepth);
|
||||
} else {
|
||||
int shift = packSize - 1;
|
||||
ICPPEvaluation[] newResult = new ICPPEvaluation[subexpressions.length + resultShift + shift];
|
||||
|
|
|
@ -1334,7 +1334,9 @@ public class CPPTemplates {
|
|||
IProblemBinding.SEMANTIC_INVALID_TYPE,
|
||||
types[i] instanceof IBinding ? ((IBinding) types[i]).getNameCharArray() : null);
|
||||
} else if (packSize == PACK_SIZE_DEFER) {
|
||||
newType = origType;
|
||||
// We're not expanding the pack, but arguments for template parameters of
|
||||
// enclosing templates may still need to be substituted into the expansion pattern.
|
||||
newType = instantiateType(origType, context);
|
||||
} else {
|
||||
IType[] newResult = new IType[result.length + packSize - 1];
|
||||
System.arraycopy(result, 0, newResult, 0, j);
|
||||
|
@ -1395,7 +1397,14 @@ public class CPPTemplates {
|
|||
throw new DOMException(new ProblemBinding(CPPSemantics.getCurrentLookupPoint(),
|
||||
IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, null));
|
||||
} else if (packSize == PACK_SIZE_DEFER) {
|
||||
// We're not expanding the pack, but arguments for template parameters of
|
||||
// enclosing templates may still need to be substituted into the expansion pattern.
|
||||
newArg = instantiateArgument(origArg, context);
|
||||
if (!isValidArgument(newArg)) {
|
||||
if (strict)
|
||||
return null;
|
||||
newArg = origArg;
|
||||
}
|
||||
} else {
|
||||
int shift = packSize - 1;
|
||||
ICPPTemplateArgument[] newResult = new ICPPTemplateArgument[args.length + resultShift + shift];
|
||||
|
|
Loading…
Add table
Reference in a new issue