mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 339977: void f(void) in template argument deduction.
This commit is contained in:
parent
69c80b5390
commit
45d8d40d08
4 changed files with 37 additions and 14 deletions
|
@ -5278,4 +5278,18 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
public void testVariadicFunctionTemplate_Bug333389() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template<typename T> void f(T(*)());
|
||||
// template<typename T> void g(T(*)(void));
|
||||
// void v1();
|
||||
// void v2(void);
|
||||
// void test() {
|
||||
// f(v1);
|
||||
// f(v2);
|
||||
// g(v1);
|
||||
// g(v2);
|
||||
// }
|
||||
public void testFunctionWithVoidParamInTypeDeduction() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -63,24 +63,21 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
|
|||
//constructors & destructors have null return type
|
||||
if ((returnType == null) ^ (ft.getReturnType() == null))
|
||||
return false;
|
||||
else if (returnType != null && ! returnType.isSameType(ft.getReturnType()))
|
||||
|
||||
if (returnType != null && ! returnType.isSameType(ft.getReturnType()))
|
||||
return false;
|
||||
|
||||
if (parameters.length == 1 && fps.length == 0) {
|
||||
if (!SemanticUtil.isVoidType(parameters[0]))
|
||||
return false;
|
||||
} else if (fps.length == 1 && parameters.length == 0) {
|
||||
if (!SemanticUtil.isVoidType(fps[0]))
|
||||
return false;
|
||||
} else if (parameters.length != fps.length) {
|
||||
return false;
|
||||
} else {
|
||||
if (parameters.length == fps.length) {
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
if (parameters[i] == null || ! parameters[i].isSameType(fps[i]))
|
||||
if (parameters[i] == null || !parameters[i].isSameType(fps[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!SemanticUtil.isEmptyParameterList(parameters)
|
||||
|| !SemanticUtil.isEmptyParameterList(fps)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -534,6 +534,16 @@ public class SemanticUtil {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEmptyParameterList(IType[] parameters) {
|
||||
if (parameters.length == 0) {
|
||||
return true;
|
||||
}
|
||||
if (parameters.length == 1 && isVoidType(parameters[0])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the number of edges in the inheritance path of <code>type</code> to
|
||||
* <code>ancestorToFind</code>, returning -1 if no inheritance relationship is found.
|
||||
|
|
|
@ -816,6 +816,8 @@ public class TemplateArgumentDeduction {
|
|||
IType[] pParams = ftp.getParameterTypes();
|
||||
IType[] aParams = fta.getParameterTypes();
|
||||
if (pParams.length != aParams.length) {
|
||||
if (SemanticUtil.isEmptyParameterList(pParams) && SemanticUtil.isEmptyParameterList(aParams))
|
||||
return true;
|
||||
if (pParams.length == 0 || pParams.length > aParams.length + 1)
|
||||
return false;
|
||||
IType lastPParam= pParams[pParams.length - 1];
|
||||
|
|
Loading…
Add table
Reference in a new issue