mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 03:45:35 +02:00
Assembler labels, bug 226121.
This commit is contained in:
parent
1ebcfc3bbd
commit
be3d297959
4 changed files with 39 additions and 20 deletions
|
@ -4457,4 +4457,12 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
parseAndCheckBindings(code, ParserLanguage.C, true);
|
parseAndCheckBindings(code, ParserLanguage.C, true);
|
||||||
parseAndCheckBindings(code, ParserLanguage.CPP, 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);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -80,24 +80,16 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
protected final AbstractParserLogService log;
|
protected final AbstractParserLogService log;
|
||||||
|
|
||||||
protected final IScanner scanner;
|
protected final IScanner scanner;
|
||||||
|
|
||||||
protected final ParserMode mode;
|
protected final ParserMode mode;
|
||||||
|
|
||||||
protected final boolean supportStatementsInExpressions;
|
protected final boolean supportStatementsInExpressions;
|
||||||
|
|
||||||
protected final boolean supportTypeOfUnaries;
|
protected final boolean supportTypeOfUnaries;
|
||||||
|
|
||||||
protected final boolean supportAlignOfUnaries;
|
protected final boolean supportAlignOfUnaries;
|
||||||
|
|
||||||
protected final boolean supportKnRC;
|
protected final boolean supportKnRC;
|
||||||
|
|
||||||
protected final boolean supportAttributeSpecifiers;
|
protected final boolean supportAttributeSpecifiers;
|
||||||
|
|
||||||
protected final boolean supportDeclspecSpecifiers;
|
protected final boolean supportDeclspecSpecifiers;
|
||||||
|
protected final IBuiltinBindingsProvider builtinBindingsProvider;
|
||||||
protected final IBuiltinBindingsProvider builtinBindingsProvider;
|
|
||||||
|
|
||||||
protected AbstractGNUSourceCodeParser(IScanner scanner,
|
protected AbstractGNUSourceCodeParser(IScanner scanner,
|
||||||
IParserLogService logService, ParserMode parserMode,
|
IParserLogService logService, ParserMode parserMode,
|
||||||
|
@ -1405,12 +1397,19 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
consume();
|
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;
|
boolean needspace= false;
|
||||||
StringBuffer buffer= new StringBuffer();
|
|
||||||
int open= 1;
|
int open= 1;
|
||||||
while (open > 0) {
|
while (open > 0) {
|
||||||
IToken t= consume();
|
t= consume();
|
||||||
switch(t.getType()) {
|
switch(t.getType()) {
|
||||||
case IToken.tLPAREN:
|
case IToken.tLPAREN:
|
||||||
open++;
|
open++;
|
||||||
|
@ -1422,18 +1421,18 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
throw new EndOfFileException();
|
throw new EndOfFileException();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (needspace) {
|
if (content != null) {
|
||||||
buffer.append(' ');
|
if (needspace) {
|
||||||
|
content.append(' ');
|
||||||
|
}
|
||||||
|
content.append(t.getCharImage());
|
||||||
|
needspace= true;
|
||||||
}
|
}
|
||||||
buffer.append(t.getCharImage());
|
|
||||||
needspace= true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int lastOffset = consume(IToken.tSEMI).getEndOffset();
|
return t;
|
||||||
|
}
|
||||||
return buildASMDirective(first.getOffset(), buffer.toString(), lastOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param offset
|
* @param offset
|
||||||
|
|
|
@ -1936,6 +1936,11 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
} while (false);
|
} 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
|
// Consume any number of __attribute__ and __declspec tokens after the parameters
|
||||||
__attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers);
|
__attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers);
|
||||||
|
|
||||||
|
|
|
@ -3825,6 +3825,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
} while (false);
|
} 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;
|
IASTDeclarator d = null;
|
||||||
if (isFunction) {
|
if (isFunction) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue