Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java33
2 files changed, 43 insertions, 8 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
index d0823a4593..d76d0ef791 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
@@ -7094,7 +7094,23 @@ public class AST2TemplateTests extends AST2TestBase {
// void test(A<int>* c) {
// f(c);
// }
- public void testAliasTemplate_416280() throws Exception {
+ public void testAliasTemplate_416280_1() throws Exception {
+ parseAndCheckBindings();
+ }
+
+ // template<typename T>
+ // struct C {};
+ //
+ // template<typename U>
+ // struct A {
+ // template<typename V>
+ // using B = C<V>;
+ // };
+ //
+ // struct D : public A<char> {
+ // B<int> b;
+ // };
+ public void testAliasTemplate_416280_2() throws Exception {
parseAndCheckBindings();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
index 3806b7a1b4..dfa6481375 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
@@ -70,6 +70,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
@@ -686,19 +687,27 @@ public class CPPTemplates {
IASTName templateName = id.getTemplateName();
IBinding template = templateName.resolvePreBinding();
- // Alias Template.
+ // Alias template.
if (template instanceof ICPPAliasTemplate) {
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) template;
- IType aliasedType = aliasTemplate.getType();
ICPPTemplateArgument[] args = createTemplateArgumentArray(id);
args = addDefaultArguments(aliasTemplate, args, id);
ICPPTemplateParameterMap parameterMap = createParameterMap(aliasTemplate, args);
+ IType aliasedType = aliasTemplate.getType();
IBinding owner = template.getOwner();
- ICPPClassSpecialization within = getSpecializationContext(owner);
- IType instantiatedType = instantiateType(aliasedType, parameterMap, -1, within, id);
- StringBuilder buf= new StringBuilder();
- buf.append(id.getSimpleID()).append(ASTTypeUtil.getArgumentListString(args, false));
- return new CPPAliasTemplateInstance(buf.toString().toCharArray(), aliasTemplate, instantiatedType);
+ return createAliasTemplaceInstance(aliasTemplate, args, parameterMap, aliasedType, owner, id);
+ }
+
+ // Alias template instance.
+ if (template instanceof ICPPAliasTemplateInstance) {
+ ICPPAliasTemplateInstance aliasTemplateInstance = (ICPPAliasTemplateInstance) template;
+ ICPPTemplateArgument[] args = createTemplateArgumentArray(id);
+ ICPPAliasTemplate aliasTemplate = aliasTemplateInstance.getTemplateDefinition();
+ args = addDefaultArguments(aliasTemplate, args, id);
+ ICPPTemplateParameterMap parameterMap = createParameterMap(aliasTemplate, args);
+ IType aliasedType = aliasTemplateInstance.getType();
+ IBinding owner = aliasTemplateInstance.getOwner();
+ return createAliasTemplaceInstance(aliasTemplate, args, parameterMap, aliasedType, owner, id);
}
// Class template.
@@ -759,6 +768,16 @@ public class CPPTemplates {
}
}
+ private static IBinding createAliasTemplaceInstance(ICPPAliasTemplate aliasTemplate,
+ ICPPTemplateArgument[] args, ICPPTemplateParameterMap parameterMap, IType aliasedType,
+ IBinding owner, ICPPASTTemplateId id) {
+ ICPPClassSpecialization within = getSpecializationContext(owner);
+ IType instantiatedType = instantiateType(aliasedType, parameterMap, -1, within, id);
+ StringBuilder buf= new StringBuilder();
+ buf.append(id.getSimpleID()).append(ASTTypeUtil.getArgumentListString(args, false));
+ return new CPPAliasTemplateInstance(buf.toString().toCharArray(), aliasTemplate, instantiatedType);
+ }
+
static boolean isClassTemplate(ICPPASTTemplateId id) {
IASTNode parentOfName = id.getParent();

Back to the top