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
b142e8e20a
commit
22747c0877
3 changed files with 25 additions and 7 deletions
|
@ -6034,4 +6034,14 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
public void testDeductionOfNonTypeTemplateArg_372587() throws Exception {
|
public void testDeductionOfNonTypeTemplateArg_372587() throws Exception {
|
||||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
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.CPPNamespaceScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
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.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.CPPUnknownBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownConstructor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownConstructor;
|
||||||
|
@ -2496,13 +2497,20 @@ public class CPPSemantics {
|
||||||
if (haveASTResult && fromIndex)
|
if (haveASTResult && fromIndex)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
boolean isCandidate;
|
||||||
if (f instanceof ICPPFunctionTemplate) {
|
if (f instanceof ICPPFunctionTemplate) {
|
||||||
// Works only if there are template arguments
|
if (args == null) {
|
||||||
if (args == null || result != null)
|
isCandidate= true;
|
||||||
return null;
|
} else {
|
||||||
result= f;
|
// See 14.3-7
|
||||||
haveASTResult= !fromIndex;
|
final ICPPTemplateParameter[] tpars = ((ICPPFunctionTemplate) f).getTemplateParameters();
|
||||||
} else if (args == null) {
|
final CPPTemplateParameterMap map = new CPPTemplateParameterMap(tpars.length);
|
||||||
|
isCandidate= TemplateArgumentDeduction.addExplicitArguments(tpars, args, map, point);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isCandidate= args == null;
|
||||||
|
}
|
||||||
|
if (isCandidate) {
|
||||||
if (result != null)
|
if (result != null)
|
||||||
return null;
|
return null;
|
||||||
result= f;
|
result= f;
|
||||||
|
|
|
@ -439,7 +439,7 @@ public class TemplateArgumentDeduction {
|
||||||
/**
|
/**
|
||||||
* Adds the explicit arguments to the map.
|
* 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) {
|
ICPPTemplateArgument[] tmplArgs, CPPTemplateParameterMap map, IASTNode point) {
|
||||||
tmplArgs= SemanticUtil.getSimplifiedArguments(tmplArgs);
|
tmplArgs= SemanticUtil.getSimplifiedArguments(tmplArgs);
|
||||||
ICPPTemplateParameter tmplParam= null;
|
ICPPTemplateParameter tmplParam= null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue