mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Bug 544681 - Support for template<auto...>
Change-Id: I059d69ee86603c1aed95eeed1be61b915df6e3ed Signed-off-by: Hannes Vogt <hannes@havogt.de>
This commit is contained in:
parent
4a35647d1f
commit
1370c76c38
2 changed files with 35 additions and 4 deletions
|
@ -11260,4 +11260,26 @@ public class AST2TemplateTests extends AST2CPPTestBase {
|
||||||
bh.assertProblem("foo(0)", 3);
|
bh.assertProblem("foo(0)", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <auto First, auto...>
|
||||||
|
// struct getFirst {
|
||||||
|
// static constexpr auto value = First;
|
||||||
|
// };
|
||||||
|
// template <auto, auto Second, auto...>
|
||||||
|
// struct getSecond {
|
||||||
|
// static constexpr auto value = Second;
|
||||||
|
// };
|
||||||
|
// template <auto... T>
|
||||||
|
// struct A {
|
||||||
|
// static constexpr auto first = getFirst<T...>::value;
|
||||||
|
// static constexpr auto second = getSecond<T...>::value;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// typedef A<42,43> B;
|
||||||
|
// static constexpr auto val1 = B::first;
|
||||||
|
// static constexpr auto val2 = B::second;
|
||||||
|
public void testVariadicTemplateAuto_544681() throws Exception {
|
||||||
|
BindingAssertionHelper helper = getAssertionHelper();
|
||||||
|
helper.assertVariableValue("val1", 42);
|
||||||
|
helper.assertVariableValue("val2", 43);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,15 +120,24 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
||||||
|
|
||||||
// C++17 template<auto>
|
// C++17 template<auto>
|
||||||
if (type instanceof CPPPlaceholderType) {
|
if (type instanceof CPPPlaceholderType) {
|
||||||
CPPDependentEvaluation eval = new EvalBinding(this, null, getPrimaryDeclaration());
|
type = getDependentTypeForAuto();
|
||||||
TypeOfDependentExpression replacementType = new TypeOfDependentExpression(eval);
|
}
|
||||||
replacementType.setForTemplateAuto(true);
|
// template<auto...>
|
||||||
type = replacementType;
|
if (type instanceof CPPParameterPackType
|
||||||
|
&& ((CPPParameterPackType) type).getType() instanceof CPPPlaceholderType) {
|
||||||
|
type = new CPPParameterPackType(getDependentTypeForAuto());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IType getDependentTypeForAuto() {
|
||||||
|
CPPDependentEvaluation eval = new EvalBinding(this, null, getPrimaryDeclaration());
|
||||||
|
TypeOfDependentExpression replacementType = new TypeOfDependentExpression(eval);
|
||||||
|
replacementType.setForTemplateAuto(true);
|
||||||
|
return replacementType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isParameterPack() {
|
public boolean isParameterPack() {
|
||||||
return getType() instanceof ICPPParameterPackType;
|
return getType() instanceof ICPPParameterPackType;
|
||||||
|
|
Loading…
Add table
Reference in a new issue