Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-08 16:10:12 +0000
committerMarkus Schorn2008-04-08 16:10:12 +0000
commitbe3d2979598fdc9f707d9cdd2c37db6ad66b8ed1 (patch)
treef3fc4256d2189d5f025a5ae2f621163d524251c8
parent1ebcfc3bbd09b6d02eea102079e9105879fe55eb (diff)
downloadorg.eclipse.cdt-be3d2979598fdc9f707d9cdd2c37db6ad66b8ed1.tar.gz
org.eclipse.cdt-be3d2979598fdc9f707d9cdd2c37db6ad66b8ed1.tar.xz
org.eclipse.cdt-be3d2979598fdc9f707d9cdd2c37db6ad66b8ed1.zip
Assembler labels, bug 226121.
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java39
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java7
4 files changed, 39 insertions, 20 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
index a0df7a24edf..deaff418d0d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
@@ -4457,4 +4457,12 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
+
+ // int foo asm ("myfoo") __attribute__((__used__)), ff asm("ss") = 2;
+ // extern void func () asm ("FUNC") __attribute__((__used__));
+ public void testASMLabels_Bug226121() throws Exception {
+ final String code = getAboveComment();
+ parseAndCheckBindings(code, ParserLanguage.C, true);
+ parseAndCheckBindings(code, ParserLanguage.CPP, true);
+ }
} \ No newline at end of file
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 27717a5bedd..ec1785d4e0a 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
@@ -80,24 +80,16 @@ import org.eclipse.cdt.core.parser.ParserMode;
public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
protected final AbstractParserLogService log;
-
protected final IScanner scanner;
-
protected final ParserMode mode;
protected final boolean supportStatementsInExpressions;
-
protected final boolean supportTypeOfUnaries;
-
protected final boolean supportAlignOfUnaries;
-
protected final boolean supportKnRC;
-
protected final boolean supportAttributeSpecifiers;
-
protected final boolean supportDeclspecSpecifiers;
-
- protected final IBuiltinBindingsProvider builtinBindingsProvider;
+ protected final IBuiltinBindingsProvider builtinBindingsProvider;
protected AbstractGNUSourceCodeParser(IScanner scanner,
IParserLogService logService, ParserMode parserMode,
@@ -1405,12 +1397,19 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
consume();
}
- consume(IToken.tLPAREN);
+ StringBuilder buffer= new StringBuilder();
+ asmExpression(buffer);
+ int lastOffset = consume(IToken.tSEMI).getEndOffset();
+
+ return buildASMDirective(first.getOffset(), buffer.toString(), lastOffset);
+ }
+
+ protected IToken asmExpression(StringBuilder content) throws EndOfFileException, BacktrackException {
+ IToken t= consume(IToken.tLPAREN);
boolean needspace= false;
- StringBuffer buffer= new StringBuffer();
int open= 1;
while (open > 0) {
- IToken t= consume();
+ t= consume();
switch(t.getType()) {
case IToken.tLPAREN:
open++;
@@ -1422,18 +1421,18 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
throw new EndOfFileException();
default:
- if (needspace) {
- buffer.append(' ');
+ if (content != null) {
+ if (needspace) {
+ content.append(' ');
+ }
+ content.append(t.getCharImage());
+ needspace= true;
}
- buffer.append(t.getCharImage());
- needspace= true;
break;
}
}
- int lastOffset = consume(IToken.tSEMI).getEndOffset();
-
- return buildASMDirective(first.getOffset(), buffer.toString(), lastOffset);
- }
+ return t;
+ }
/**
* @param offset
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
index 6b67e444f57..7746eaf04b2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
@@ -1936,6 +1936,11 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
} while (false);
+ if (LT(1) == IToken.t_asm) { // asm labels bug 226121
+ consume();
+ finalOffset= asmExpression(null).getEndOffset();
+ }
+
// Consume any number of __attribute__ and __declspec tokens after the parameters
__attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index fd2149b56a4..da094cfe676 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -3825,6 +3825,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
} while (false);
+ if (LT(1) == IToken.t_asm) { // asm labels bug 226121
+ consume();
+ finalOffset= asmExpression(null).getEndOffset();
+ }
+ if(supportAttributeSpecifiers)
+ __attribute_decl_seq(supportAttributeSpecifiers, false);
+
IASTDeclarator d = null;
if (isFunction) {

Back to the top