From c7b6aa3bd58ebb3e6ffaebd0cb1e3222ceb677d4 Mon Sep 17 00:00:00 2001 From: Thomas Corbat Date: Fri, 11 Aug 2017 14:29:02 +0200 Subject: [PATCH] Bug 520893 Pack expansion in IASTTypeId is lost Change-Id: I9137d028c56ce62ee02571099a7a5ab1b2b481cd Signed-off-by: Thomas Corbat --- .../ASTWriterDeclarationTestSource.awts | 10 ++++++++++ .../rewrite/astwriter/ASTWriterVisitor.java | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclarationTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclarationTestSource.awts index 14653f5cc88..b0ded6c335e 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclarationTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclarationTestSource.awts @@ -113,3 +113,13 @@ int i = 2; //%CPP typename T::A* a6; +//!Variadic Template +//%CPP +template struct Tpl +{ +}; + +template +void foo(Tpl) +{ +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java index b4c65fdbaf4..f832ae4ec45 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java @@ -32,10 +32,12 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId; import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.parser.Keywords; @@ -290,6 +292,22 @@ public class ASTWriterVisitor extends ASTVisitor { return ASTVisitor.PROCESS_SKIP; } + @Override + public int visit(IASTTypeId typeId) { + IASTDeclSpecifier declSpecifier = typeId.getDeclSpecifier(); + if (declSpecifier != null) declSpecifier.accept(this); + if (typeId instanceof ICPPASTTypeId) { + if (((ICPPASTTypeId) typeId).isPackExpansion()) { + scribe.print(Keywords.cpELLIPSIS); + } + } + IASTDeclarator declarator = typeId.getAbstractDeclarator(); + if (declarator != null) { + declarator.accept(this); + } + return ASTVisitor.PROCESS_SKIP; + } + protected IASTName getParameterName(IASTDeclarator declarator) { return declarator.getName(); }