mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 379604: Discard template functions where explicit args do not match from function set.
This commit is contained in:
parent
46b4d35b0b
commit
6a26b2524d
3 changed files with 25 additions and 7 deletions
|
@ -6031,4 +6031,14 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
public void testDeductionOfNonTypeTemplateArg_372587() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
|
||||
// template<typename _Functor> void b(_Functor __f) {}
|
||||
// template<typename T, typename V> void f(T __first, T __last, const V& __val) {}
|
||||
// template<typename T> void f(T __first, T __last, const T& __val) {}
|
||||
// void test() {
|
||||
// b(f<int*, int>);
|
||||
// }
|
||||
public void testFunctionSetWithNonMatchingTemplateArgs_379604() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,6 +196,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNamespace;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNamespaceScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownConstructor;
|
||||
|
@ -2496,13 +2497,20 @@ public class CPPSemantics {
|
|||
if (haveASTResult && fromIndex)
|
||||
break;
|
||||
|
||||
boolean isCandidate;
|
||||
if (f instanceof ICPPFunctionTemplate) {
|
||||
// Works only if there are template arguments
|
||||
if (args == null || result != null)
|
||||
return null;
|
||||
result= f;
|
||||
haveASTResult= !fromIndex;
|
||||
} else if (args == null) {
|
||||
if (args == null) {
|
||||
isCandidate= true;
|
||||
} else {
|
||||
// See 14.3-7
|
||||
final ICPPTemplateParameter[] tpars = ((ICPPFunctionTemplate) f).getTemplateParameters();
|
||||
final CPPTemplateParameterMap map = new CPPTemplateParameterMap(tpars.length);
|
||||
isCandidate= TemplateArgumentDeduction.addExplicitArguments(tpars, args, map, point);
|
||||
}
|
||||
} else {
|
||||
isCandidate= args == null;
|
||||
}
|
||||
if (isCandidate) {
|
||||
if (result != null)
|
||||
return null;
|
||||
result= f;
|
||||
|
|
|
@ -439,7 +439,7 @@ public class TemplateArgumentDeduction {
|
|||
/**
|
||||
* Adds the explicit arguments to the map.
|
||||
*/
|
||||
private static boolean addExplicitArguments(final ICPPTemplateParameter[] tmplParams,
|
||||
public static boolean addExplicitArguments(final ICPPTemplateParameter[] tmplParams,
|
||||
ICPPTemplateArgument[] tmplArgs, CPPTemplateParameterMap map, IASTNode point) {
|
||||
tmplArgs= SemanticUtil.getSimplifiedArguments(tmplArgs);
|
||||
ICPPTemplateParameter tmplParam= null;
|
||||
|
|
Loading…
Add table
Reference in a new issue