1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Bug 351609: Adjust parameter types in instantiated function type.

This commit is contained in:
Markus Schorn 2011-07-20 14:01:49 +02:00
parent 34fdfb1196
commit d226e960f9
3 changed files with 22 additions and 1 deletions

View file

@ -5402,4 +5402,18 @@ public class AST2TemplateTests extends AST2BaseTest {
public void testAddressOfMethodForInstantiation_Bug344310() throws Exception {
parseAndCheckBindings();
}
// template<typename Arg> struct Callback {
// Callback(void (*function)(Arg arg)) {}
// };
//
// void Subscribe(const Callback<const int>& callback){}
// void CallMe(const int){}
//
// int test() {
// Subscribe(Callback<const int>(&CallMe)); // invalid arguments, symbol not
// }
public void testParameterAdjustementInInstantiatedFunctionType_351609() throws Exception {
parseAndCheckBindings();
}
}

View file

@ -1054,6 +1054,13 @@ public class CPPTemplates {
if (ret == r && params == ps) {
return type;
}
// The parameter types need to be adjusted.
for (int i=0; i<params.length; i++) {
IType p= params[i];
if (!isDependentType(p)) {
params[i]= CPPVisitor.adjustParameterType(p, true);
}
}
return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
}

View file

@ -1723,7 +1723,7 @@ public class CPPVisitor extends ASTQueries {
* Adjusts the parameter type according to 8.3.5-3:
* cv-qualifiers are deleted, arrays and function types are converted to pointers.
*/
private static IType adjustParameterType(final IType pt, boolean forFunctionType) {
static IType adjustParameterType(final IType pt, boolean forFunctionType) {
// bug 239975
IType t= SemanticUtil.getNestedType(pt, TDEF);
if (t instanceof IArrayType) {