1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +02:00

Bug 511658 - Destructor call via alias template name

Change-Id: I64a7ec62a05345983e9e298a6ba735f63385486b
This commit is contained in:
Nathan Ridge 2017-02-05 01:52:58 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent ac8224f763
commit c0ba7f6bfb
2 changed files with 37 additions and 3 deletions

View file

@ -10106,6 +10106,19 @@ public class AST2TemplateTests extends AST2TestBase {
parseAndCheckBindings();
}
// template <class T>
// using alias = T;
//
// struct A {};
//
// void foo() {
// A a;
// a.~alias<A>();
// }
public void testDestructorCallViaAliasedTemplateName_511658() throws Exception {
parseAndCheckBindings();
}
// template <typename> struct Waldo {};
// Waldo<void() noexcept> var;
public void testNoexceptSpecifierInTypeTemplateArgument_511186() throws Exception {

View file

@ -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;
@ -1188,7 +1189,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;
@ -1197,10 +1199,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;