mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42: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);
|
||||
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
|
||||
implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization {
|
||||
|
||||
private ICPPTemplateArgument[] arguments;
|
||||
private final ICPPTemplateArgument[] arguments;
|
||||
|
||||
public CPPClassTemplatePartialSpecialization(ICPPASTTemplateId name) {
|
||||
public CPPClassTemplatePartialSpecialization(ICPPASTTemplateId name, ICPPTemplateArgument[] arguments) {
|
||||
super(name);
|
||||
this.arguments= arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument[] getTemplateArguments() throws DOMException {
|
||||
if (arguments == null) {
|
||||
arguments= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) getTemplateName());
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
|
|
@ -677,10 +677,14 @@ public class CPPTemplates {
|
|||
if (argsAreTrivial(classTemplate.getTemplateParameters(), args)) {
|
||||
result= classTemplate;
|
||||
} else {
|
||||
args= addDefaultArguments(classTemplate, args);
|
||||
if (args == null) {
|
||||
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray());
|
||||
}
|
||||
ICPPClassTemplatePartialSpecialization partialSpec= findPartialSpecialization(classTemplate, args);
|
||||
if (isDeclaration || isDefinition) {
|
||||
if (partialSpec == null) {
|
||||
partialSpec = new CPPClassTemplatePartialSpecialization(id);
|
||||
partialSpec = new CPPClassTemplatePartialSpecialization(id, args);
|
||||
if (template instanceof ICPPInternalClassTemplate)
|
||||
((ICPPInternalClassTemplate) template).addPartialSpecialization(partialSpec);
|
||||
return partialSpec;
|
||||
|
|
Loading…
Add table
Reference in a new issue