mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 526684 - Use InstantiationContext.setExpandPack() in CPPTemplates.instantiateTypes() if appropriate
InstantiationContext.setExpandPack() and related methods were introduced in bug 486971 to ensure that when instantiating a type list that contains a pack expansion, with a parameter map that maps the template parameter pack that appears in the expansion to another parameter pack (which can happen when e.g. instantiating an alias template with dependent arguments), the pack is expanded in the correct place. However, bug 486971 only added use of this machinery to CPPTemplates. instantiateArguments(). We can also instantiate a type list in instantiateTypes() (used e.g. when instantiating the parameter types of a function type), so the machinery needs to be used there as well. Change-Id: Iabb458e8e3166c15ed922656fc0729a4a8cf8bbf
This commit is contained in:
parent
76e1842644
commit
daad877559
2 changed files with 28 additions and 1 deletions
|
@ -9017,6 +9017,24 @@ public class AST2TemplateTests extends AST2CPPTestBase {
|
|||
public void testDecltypeInPackExpansion_486425b() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename T>
|
||||
// class meta {
|
||||
// typedef T type;
|
||||
// };
|
||||
//
|
||||
// template <typename... Ts>
|
||||
// using Alias = void(typename meta<Ts>::type...);
|
||||
//
|
||||
// template <typename... Ts>
|
||||
// Alias<Ts...>* async(Ts...);
|
||||
//
|
||||
// int main() {
|
||||
// async(); // ERROR: Invalid arguments
|
||||
// }
|
||||
public void testDependentPackExpansionInFunctionType_526684() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename T>
|
||||
// struct A {};
|
||||
|
|
|
@ -1304,12 +1304,21 @@ public class CPPTemplates {
|
|||
IType[] newResult= new IType[result.length + packSize - 1];
|
||||
System.arraycopy(result, 0, newResult, 0, j);
|
||||
result= newResult;
|
||||
context.setExpandPack(true);
|
||||
int oldPackOffset = context.getPackOffset();
|
||||
for (int k= 0; k < packSize; k++) {
|
||||
context.setPackOffset(k);
|
||||
result[j++]= instantiateType(innerType, context);
|
||||
IType instantiated = instantiateType(innerType, context);
|
||||
if (context.isPackExpanded()) {
|
||||
if (instantiated != null) {
|
||||
instantiated = new CPPParameterPackType(instantiated);
|
||||
}
|
||||
}
|
||||
result[j++]= instantiated;
|
||||
|
||||
}
|
||||
context.setPackOffset(oldPackOffset);
|
||||
context.setExpandPack(false);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue