mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 367997: Partial class template specialization using default arguments.
This commit is contained in:
parent
7d0d64393c
commit
99fa95b7cd
3 changed files with 18 additions and 6 deletions
|
@ -5703,4 +5703,14 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
ICPPDeferredClassInstance shortHand= bh.assertNonProblem("derived:", -1);
|
ICPPDeferredClassInstance shortHand= bh.assertNonProblem("derived:", -1);
|
||||||
assertTrue(shortHand.getClassTemplate() instanceof ICPPClassTemplatePartialSpecialization);
|
assertTrue(shortHand.getClassTemplate() instanceof ICPPClassTemplatePartialSpecialization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename> class A {};
|
||||||
|
// template <typename T, typename=void> struct B {};
|
||||||
|
// template <typename T> struct B<A<T> > {
|
||||||
|
// typedef int type;
|
||||||
|
// };
|
||||||
|
// typedef B<A<int> >::type type; // ERROR HERE
|
||||||
|
public void testPartialClassTemplateSpecUsingDefaultArgument_367997() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,17 +33,15 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate
|
public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate
|
||||||
implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization {
|
implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization {
|
||||||
|
|
||||||
private ICPPTemplateArgument[] arguments;
|
private final ICPPTemplateArgument[] arguments;
|
||||||
|
|
||||||
public CPPClassTemplatePartialSpecialization(ICPPASTTemplateId name) {
|
public CPPClassTemplatePartialSpecialization(ICPPASTTemplateId name, ICPPTemplateArgument[] arguments) {
|
||||||
super(name);
|
super(name);
|
||||||
|
this.arguments= arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPTemplateArgument[] getTemplateArguments() throws DOMException {
|
public ICPPTemplateArgument[] getTemplateArguments() throws DOMException {
|
||||||
if (arguments == null) {
|
|
||||||
arguments= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) getTemplateName());
|
|
||||||
}
|
|
||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -677,10 +677,14 @@ public class CPPTemplates {
|
||||||
if (argsAreTrivial(classTemplate.getTemplateParameters(), args)) {
|
if (argsAreTrivial(classTemplate.getTemplateParameters(), args)) {
|
||||||
result= classTemplate;
|
result= classTemplate;
|
||||||
} else {
|
} else {
|
||||||
|
args= addDefaultArguments(classTemplate, args);
|
||||||
|
if (args == null) {
|
||||||
|
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray());
|
||||||
|
}
|
||||||
ICPPClassTemplatePartialSpecialization partialSpec= findPartialSpecialization(classTemplate, args);
|
ICPPClassTemplatePartialSpecialization partialSpec= findPartialSpecialization(classTemplate, args);
|
||||||
if (isDeclaration || isDefinition) {
|
if (isDeclaration || isDefinition) {
|
||||||
if (partialSpec == null) {
|
if (partialSpec == null) {
|
||||||
partialSpec = new CPPClassTemplatePartialSpecialization(id);
|
partialSpec = new CPPClassTemplatePartialSpecialization(id, args);
|
||||||
if (template instanceof ICPPInternalClassTemplate)
|
if (template instanceof ICPPInternalClassTemplate)
|
||||||
((ICPPInternalClassTemplate) template).addPartialSpecialization(partialSpec);
|
((ICPPInternalClassTemplate) template).addPartialSpecialization(partialSpec);
|
||||||
return partialSpec;
|
return partialSpec;
|
||||||
|
|
Loading…
Add table
Reference in a new issue