From 90c6b6c0e97c125a2983e6a92e20b016d1aa06eb Mon Sep 17 00:00:00 2001 From: Neuromancer42 Date: Mon, 7 Nov 2022 00:31:30 +0800 Subject: [PATCH] fix omitted parentheses in extended ASM #134 --- .../rewrite/ASTWriterDeclarationTestSource.awts | 4 ++++ .../dom/parser/AbstractGNUSourceCodeParser.java | 15 ++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) 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 e15e59ece6f..cc6ec95b5a8 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclarationTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclarationTestSource.awts @@ -2,6 +2,10 @@ //%CPP asm("movl %1, %%eax;"); +//!GNUExtendedASMDeclarationTest +//%CPP GNU +asm("bswap %0" : "+r" (_data)); + //!FunctionDefinitionTest //%CPP int foo() diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java index 58e28e2f276..9b7b8232643 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java @@ -1927,16 +1927,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { break; case IToken.tEOC: throw new EndOfFileException(t.getOffset()); - - default: - if (content != null) { - if (needspace) { - content.append(' '); - } - content.append(t.getCharImage()); - needspace = true; + } + if (open > 0 && content != null) { + if (needspace) { + content.append(' '); } - break; + content.append(t.getCharImage()); + needspace = true; } } return t;