From 69665fb3523658b9dc187427bbbef12d515f1b98 Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Sun, 1 Aug 2010 23:46:36 +0000 Subject: [PATCH] Bug 319044 DeclaratorWriter unable to write a rvalue reference (patch from Tomasz Wesolowski) --- .../resources/rewrite/ASTWriterDeclaratorTestSource.awts | 7 +++++++ .../core/dom/rewrite/astwriter/DeclaratorWriter.java | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts index b5e0ab31b18..d1adcb49b01 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts @@ -92,3 +92,10 @@ int b, a; } +//!ICPPASTReferenceOperator rvalue reference +//%CPP +int && foo(int && a) +{ + char && b; +} + diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java index ce5714b5aa0..b20d2542f6c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java @@ -48,6 +48,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; public class DeclaratorWriter extends NodeWriter { private static final String AMPERSAND_SPACE = "& "; //$NON-NLS-1$ + private static final String AMPERSAND__AMPERSAND_SPACE = "&& "; //$NON-NLS-1$ private static final String STAR_SPACE = "* "; //$NON-NLS-1$ private static final String PURE_VIRTUAL = " =0"; //$NON-NLS-1$ @@ -197,8 +198,12 @@ public class DeclaratorWriter extends NodeWriter { if (operator instanceof IASTPointer) { IASTPointer pointOp = (IASTPointer) operator; writePointer(pointOp); - }else if (operator instanceof ICPPASTReferenceOperator) { - scribe.print(AMPERSAND_SPACE); + } else if (operator instanceof ICPPASTReferenceOperator) { + if (((ICPPASTReferenceOperator) operator).isRValueReference()) { + scribe.print(AMPERSAND__AMPERSAND_SPACE); + } else { + scribe.print(AMPERSAND_SPACE); + } } }