mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Bug 527697 - Size of parameter pack where arguments themselves contain a pack
Change-Id: I850eaf74a3fb3ec4b160aedc3f594ff0d0edf31a
This commit is contained in:
parent
abf1b13e6b
commit
193cb87bfa
2 changed files with 28 additions and 1 deletions
|
@ -9036,6 +9036,24 @@ public class AST2TemplateTests extends AST2CPPTestBase {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <int> struct __make;
|
||||||
|
// template <> struct __make<2> { typedef int type; };
|
||||||
|
//
|
||||||
|
// template <typename... T>
|
||||||
|
// using type_pack_element = typename __make<sizeof...(T)>::type;
|
||||||
|
//
|
||||||
|
// template <typename... T>
|
||||||
|
// struct tuple_element {
|
||||||
|
// typedef type_pack_element<T...> type;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// typedef tuple_element<int, int>::type Waldo;
|
||||||
|
public void testSizeofParameterPack_527697() throws Exception {
|
||||||
|
BindingAssertionHelper helper = getAssertionHelper();
|
||||||
|
ITypedef waldo = helper.assertNonProblem("Waldo");
|
||||||
|
assertSameType(CommonCPPTypes.int_, waldo);
|
||||||
|
}
|
||||||
|
|
||||||
// template <typename T>
|
// template <typename T>
|
||||||
// struct A {};
|
// struct A {};
|
||||||
//
|
//
|
||||||
|
|
|
@ -1221,8 +1221,17 @@ public class CPPTemplates {
|
||||||
static int determinePackSize(ICPPTemplateParameter tpar, ICPPTemplateParameterMap tpMap) {
|
static int determinePackSize(ICPPTemplateParameter tpar, ICPPTemplateParameterMap tpMap) {
|
||||||
if (tpar.isParameterPack()) {
|
if (tpar.isParameterPack()) {
|
||||||
ICPPTemplateArgument[] args= tpMap.getPackExpansion(tpar);
|
ICPPTemplateArgument[] args= tpMap.getPackExpansion(tpar);
|
||||||
if (args != null)
|
if (args != null) {
|
||||||
|
// The arguments could be dependent, so they could themselves
|
||||||
|
// contain pack expansions.
|
||||||
|
for (ICPPTemplateArgument arg : args) {
|
||||||
|
if (arg.isPackExpansion()) {
|
||||||
|
return PACK_SIZE_DEFER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return args.length;
|
return args.length;
|
||||||
|
}
|
||||||
return PACK_SIZE_DEFER;
|
return PACK_SIZE_DEFER;
|
||||||
}
|
}
|
||||||
return PACK_SIZE_NOT_FOUND;
|
return PACK_SIZE_NOT_FOUND;
|
||||||
|
|
Loading…
Add table
Reference in a new issue