From e74d8ad4d66417dcf89c5ac616da7866167f276a Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Fri, 7 Mar 2014 01:05:27 -0500 Subject: [PATCH] Bug 424898 - Parenthesis around reference argument in C++ file Change-Id: Ief6cf4daa396a48f11a1aa5bcbec0746f6421ef0 Signed-off-by: Nathan Ridge Reviewed-on: https://git.eclipse.org/r/23024 Reviewed-by: Sergey Prigogin IP-Clean: Sergey Prigogin Tested-by: Sergey Prigogin --- .../cdt/core/parser/tests/ast2/AST2CPPTests.java | 5 +++++ .../core/dom/parser/cpp/CPPASTDeclarator.java | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 8646f697ac1..e72d2f8efc2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -10567,4 +10567,9 @@ public class AST2CPPTests extends AST2TestBase { public void testFieldAndNestedTypeWithSameName_425033() throws Exception { parseAndCheckBindings(); } + + // void f(double (&(x))); + public void testParenthesizedReferenceArgument_424898() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java index c3f13144c5f..e6b84d80805 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java @@ -36,13 +36,15 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; +import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** * C++ specific declarator. */ -public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator, IASTImplicitNameOwner { +public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator, IASTImplicitNameOwner, + IASTAmbiguityParent { private IASTInitializer initializer; private IASTName name; private IASTImplicitName[] implicitNames; @@ -318,4 +320,13 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator, IAST return implicitNames; } + + @Override + public void replace(IASTNode child, IASTNode other) { + if (child == nested) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); + nested= (IASTDeclarator) other; + } + } }