mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Constructor template in class template.
This commit is contained in:
parent
5a3544dc81
commit
1c7f9d1e34
2 changed files with 19 additions and 10 deletions
|
@ -3770,4 +3770,18 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||
bh.assertNonProblem("A<C> make_A(C* p) {", 4, ICPPTemplateInstance.class);
|
||||
}
|
||||
|
||||
// template <typename T> class CT {
|
||||
// public:
|
||||
// template <typename U> CT(U u) {}
|
||||
// };
|
||||
// template <typename T> void any(T t) {}
|
||||
// void test() {
|
||||
// int* iptr;
|
||||
// any(CT<int>(iptr));
|
||||
// }
|
||||
public void testConstructorTemplateInClassTemplate() throws Exception {
|
||||
String code= getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -607,15 +607,6 @@ public class CPPTemplates {
|
|||
parentOfName= parentOfName.getParent();
|
||||
}
|
||||
|
||||
IASTNode parentOfDeclaration= parentOfName;
|
||||
while (parentOfDeclaration != null) {
|
||||
if (parentOfDeclaration instanceof IASTDeclaration) {
|
||||
parentOfDeclaration= parentOfDeclaration.getParent();
|
||||
break;
|
||||
}
|
||||
parentOfDeclaration= parentOfDeclaration.getParent();
|
||||
}
|
||||
|
||||
return parentOfName instanceof ICPPASTElaboratedTypeSpecifier ||
|
||||
parentOfName instanceof ICPPASTCompositeTypeSpecifier ||
|
||||
parentOfName instanceof ICPPASTNamedTypeSpecifier ||
|
||||
|
@ -1368,7 +1359,11 @@ public class CPPTemplates {
|
|||
ICPPFunctionTemplate template = (ICPPFunctionTemplate) templates.keyAt(idx);
|
||||
CPPTemplateParameterMap map= new CPPTemplateParameterMap(fnArgs.length);
|
||||
try {
|
||||
ICPPTemplateArgument[] args= deduceTemplateFunctionArguments(template, templateArguments, fnArgs, map);
|
||||
ICPPTemplateArgument[] useArgs = templateArguments;
|
||||
if (template instanceof ICPPConstructor)
|
||||
useArgs= ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
|
||||
ICPPTemplateArgument[] args= deduceTemplateFunctionArguments(template, useArgs, fnArgs, map);
|
||||
if (args != null) {
|
||||
IBinding temp= instantiateFunctionTemplate(template, args);
|
||||
if (temp instanceof IFunction) {
|
||||
|
|
Loading…
Add table
Reference in a new issue