mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
Bug 324096: Function parameter packs in non final positions, c++ issue 818.
This commit is contained in:
parent
737591823b
commit
e378c67b8a
4 changed files with 37 additions and 17 deletions
|
@ -9059,4 +9059,19 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
dtor= (IASTImplicitNameOwner) name.getParent();
|
dtor= (IASTImplicitNameOwner) name.getParent();
|
||||||
assertSame(ctor3, dtor.getImplicitNames()[0].resolveBinding());
|
assertSame(ctor3, dtor.getImplicitNames()[0].resolveBinding());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// namespace A {
|
||||||
|
// inline namespace B {
|
||||||
|
// namespace C {
|
||||||
|
// int i;
|
||||||
|
// }
|
||||||
|
// using namespace C;
|
||||||
|
// }
|
||||||
|
// int i;
|
||||||
|
// }
|
||||||
|
// int j = A::i;
|
||||||
|
public void testInlineNamespaceLookup_324096() throws Exception {
|
||||||
|
String code= getAboveComment();
|
||||||
|
parseAndCheckBindings(code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5106,5 +5106,14 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
public void testOverloadResolutionBetweenMethodTemplateAndFunction() throws Exception {
|
public void testOverloadResolutionBetweenMethodTemplateAndFunction() throws Exception {
|
||||||
final String code= getAboveComment();
|
final String code= getAboveComment();
|
||||||
parseAndCheckBindings(code);
|
parseAndCheckBindings(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename ...T> void f(T..., T...);
|
||||||
|
// void test() {
|
||||||
|
// f(1,1);
|
||||||
|
// }
|
||||||
|
public void testFunctionParameterPacksInNonFinalPosition_324096() throws Exception {
|
||||||
|
final String code= getAboveComment();
|
||||||
|
parseAndCheckBindings(code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -922,23 +922,20 @@ public class CPPTemplates {
|
||||||
IType origType = types[i];
|
IType origType = types[i];
|
||||||
IType newType;
|
IType newType;
|
||||||
if (origType instanceof ICPPParameterPackType) {
|
if (origType instanceof ICPPParameterPackType) {
|
||||||
if (i != types.length-1) {
|
origType= ((ICPPParameterPackType) origType).getType();
|
||||||
|
int packSize= determinePackSize(origType, tpMap);
|
||||||
|
if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) {
|
||||||
newType= new ProblemBinding(null, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
newType= new ProblemBinding(null, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||||
|
} else if (packSize == PACK_SIZE_DEFER) {
|
||||||
|
newType= origType;
|
||||||
} else {
|
} else {
|
||||||
origType= ((ICPPParameterPackType) origType).getType();
|
IType[] packResult= new IType[types.length+packSize-1];
|
||||||
int packSize= determinePackSize(origType, tpMap);
|
System.arraycopy(result, 0, packResult, 0, types.length-1);
|
||||||
if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) {
|
for(int j=0; j<packSize; j++) {
|
||||||
newType= new ProblemBinding(null, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
packResult[i+j]= CPPTemplates.instantiateType(origType, tpMap, j, within);
|
||||||
} else if (packSize == PACK_SIZE_DEFER) {
|
|
||||||
newType= origType;
|
|
||||||
} else {
|
|
||||||
IType[] packResult= new IType[types.length+packSize-1];
|
|
||||||
System.arraycopy(result, 0, packResult, 0, types.length-1);
|
|
||||||
for(int j=0; j<packSize; j++) {
|
|
||||||
packResult[i+j]= CPPTemplates.instantiateType(origType, tpMap, j, within);
|
|
||||||
}
|
|
||||||
return packResult;
|
|
||||||
}
|
}
|
||||||
|
result= packResult;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within);
|
newType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within);
|
||||||
|
|
|
@ -171,9 +171,8 @@ public class TemplateArgumentDeduction {
|
||||||
} else if (j < fnParCount) {
|
} else if (j < fnParCount) {
|
||||||
par= fnPars[j];
|
par= fnPars[j];
|
||||||
if (par instanceof ICPPParameterPackType) {
|
if (par instanceof ICPPParameterPackType) {
|
||||||
// must be the last parameter.
|
|
||||||
if (j != fnParCount - 1)
|
if (j != fnParCount - 1)
|
||||||
return false;
|
continue; // non-deduced context
|
||||||
|
|
||||||
par= fnParPack= ((ICPPParameterPackType) par).getType();
|
par= fnParPack= ((ICPPParameterPackType) par).getType();
|
||||||
deduct= new TemplateArgumentDeduction(deduct, fnArgs.length - j);
|
deduct= new TemplateArgumentDeduction(deduct, fnArgs.length - j);
|
||||||
|
|
Loading…
Add table
Reference in a new issue