1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Bug 324096: Function parameter packs in non final positions, c++ issue 818.

This commit is contained in:
Markus Schorn 2010-09-09 12:03:39 +00:00
parent 737591823b
commit e378c67b8a
4 changed files with 37 additions and 17 deletions

View file

@ -9059,4 +9059,19 @@ public class AST2CPPTests extends AST2BaseTest {
dtor= (IASTImplicitNameOwner) name.getParent();
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);
}
}

View file

@ -5106,5 +5106,14 @@ public class AST2TemplateTests extends AST2BaseTest {
public void testOverloadResolutionBetweenMethodTemplateAndFunction() throws Exception {
final String code= getAboveComment();
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);
}
}

View file

@ -922,23 +922,20 @@ public class CPPTemplates {
IType origType = types[i];
IType newType;
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);
} else if (packSize == PACK_SIZE_DEFER) {
newType= origType;
} else {
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);
} 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;
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);
}
result= packResult;
continue;
}
} else {
newType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within);

View file

@ -171,9 +171,8 @@ public class TemplateArgumentDeduction {
} else if (j < fnParCount) {
par= fnPars[j];
if (par instanceof ICPPParameterPackType) {
// must be the last parameter.
if (j != fnParCount - 1)
return false;
continue; // non-deduced context
par= fnParPack= ((ICPPParameterPackType) par).getType();
deduct= new TemplateArgumentDeduction(deduct, fnArgs.length - j);