1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Fixes a NPE, bug 244384.

This commit is contained in:
Markus Schorn 2008-09-02 09:05:26 +00:00
parent 35c7928f5e
commit 63563deaf8

View file

@ -1696,21 +1696,18 @@ public class CPPTemplates {
// Using the transformed parameter list, perform argument deduction against the other // Using the transformed parameter list, perform argument deduction against the other
// function template // function template
ObjectMap m1 = null; ObjectMap m1 = null;
if (f1 != null) {
IType[] args = createArgsForFunctionTemplateOrdering(f1);
IBinding function = instantiate(f1, args);
if (function instanceof ICPPFunction)
m1 = deduceTemplateArguments(f2, ((ICPPFunction) function).getType().getParameterTypes());
}
ObjectMap m2 = null; ObjectMap m2 = null;
if (f2 != null) {
IType[] args = createArgsForFunctionTemplateOrdering(f2);
IBinding function = instantiate(f2, args);
if (function instanceof ICPPFunction) IType[] args = createArgsForFunctionTemplateOrdering(f1);
m2 = deduceTemplateArguments(f1, ((ICPPFunction) function).getType().getParameterTypes()); IBinding function = instantiate(f1, args);
} if (function instanceof ICPPFunction)
m1 = deduceTemplateArguments(f2, ((ICPPFunction) function).getType().getParameterTypes());
args = createArgsForFunctionTemplateOrdering(f2);
function = instantiate(f2, args);
if (function instanceof ICPPFunction)
m2 = deduceTemplateArguments(f1, ((ICPPFunction) function).getType().getParameterTypes());
// The transformed template is at least as specialized as the other iff the deduction // The transformed template is at least as specialized as the other iff the deduction
// succeeds and the deduced parameter types are an exact match. // succeeds and the deduced parameter types are an exact match.
// A template is more specialized than another iff it is at least as specialized as the // A template is more specialized than another iff it is at least as specialized as the
@ -1802,17 +1799,16 @@ public class CPPTemplates {
} }
//to order class template specializations, we need to transform them into function templates //to order class template specializations, we need to transform them into function templates
ICPPFunctionTemplate template1 = null, template2 = null; ICPPFunctionTemplate template1 = classTemplateSpecializationToFunctionTemplate(spec1);
ICPPFunctionTemplate template2 = classTemplateSpecializationToFunctionTemplate(spec2);
// if (spec1 instanceof ICPPClassType) { if (template1 == null) {
template1 = classTemplateSpecializationToFunctionTemplate(spec1); if (template2 == null)
template2 = classTemplateSpecializationToFunctionTemplate(spec2); return 0;
// } return 1;
// else if (spec1 instanceof ICPPFunction) { }
// template1 = (ICPPFunctionTemplate) spec1; if (template2 == null)
// template2 = (ICPPFunctionTemplate) spec2; return -1;
// }
return orderTemplateFunctions(template1, template2); return orderTemplateFunctions(template1, template2);
} }