Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-02-05 01:52:58 -0500
committerNathan Ridge2017-02-12 17:57:27 -0500
commite6b9bee424bfaf0792dd60f876201f9c3c22f759 (patch)
tree07bc63c5718dc062f16461819f3800c2fa7dea63
parentb2b1e17b379b6e7c9af9174cc7862382efeaec82 (diff)
downloadorg.eclipse.cdt-e6b9bee424bfaf0792dd60f876201f9c3c22f759.tar.gz
org.eclipse.cdt-e6b9bee424bfaf0792dd60f876201f9c3c22f759.tar.xz
org.eclipse.cdt-e6b9bee424bfaf0792dd60f876201f9c3c22f759.zip
Bug 511658 - Destructor call via alias template name
-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 6b846e33a3..0fcde0e826 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 99e20dcb7a..6ed4003bd3 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