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.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java27
2 files changed, 37 insertions, 3 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 6b846e33a3c..0fcde0e826c 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
@@ -9977,4 +9977,17 @@ public class AST2TemplateTests extends AST2TestBase {
public void testDependentDestructorName_511122() throws Exception {
parseAndCheckBindings();
}
+
+ // template <class T>
+ // using alias = T;
+ //
+ // struct A {};
+ //
+ // void foo() {
+ // A a;
+ // a.~alias<A>();
+ // }
+ public void testDestructorCallViaAliasedTemplateName_511658() throws Exception {
+ parseAndCheckBindings();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index 99e20dcb7a5..6ed4003bd39 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -142,6 +142,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
@@ -1176,7 +1177,8 @@ public class CPPSemantics {
char[] tchars= new char[typeDtorChars.length - 1];
System.arraycopy(typeDtorChars, 1, tchars, 0, tchars.length);
- LookupData ld2= new LookupData(tchars, data.getTemplateArguments(), data.getLookupPoint());
+ ICPPTemplateArgument[] templateArgs = data.getTemplateArguments();
+ LookupData ld2= new LookupData(tchars, templateArgs, data.getLookupPoint());
ld2.setIgnorePointOfDeclaration(data.isIgnorePointOfDeclaration());
ld2.contentAssist= data.contentAssist;
ld2.fNoNarrowing= data.fNoNarrowing;
@@ -1185,10 +1187,29 @@ public class CPPSemantics {
ld2.typesOnly= true;
lookup(ld2, getLookupScope(typeDtorName));
IBinding[] typedefs = ld2.getFoundBindings();
- if (typedefs.length < 1 || !(typedefs[0] instanceof ITypedef))
+ ITypedef typedef = null;
+ for (IBinding candidate : typedefs) {
+ if (!(candidate instanceof IType)) {
+ continue;
+ }
+ IType type = (IType) candidate;
+ if (templateArgs != null && type instanceof ICPPAliasTemplate) {
+ IBinding instantiated = CPPTemplates.instantiateAliasTemplate((ICPPAliasTemplate) type,
+ templateArgs, data.getLookupPoint());
+ if (instantiated instanceof IType) {
+ type = (IType) instantiated;
+ }
+ }
+ if (type instanceof ITypedef) {
+ typedef = (ITypedef) type;
+ break;
+ }
+ }
+ if (typedef == null) {
return false;
+ }
- IType t= SemanticUtil.getNestedType((ITypedef) typedefs[0], TDEF);
+ IType t= SemanticUtil.getNestedType(typedef, TDEF);
if (t instanceof ICPPUnknownBinding || t instanceof ISemanticProblem ||
!(t instanceof ICPPClassType)) {
return false;

Back to the top