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.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 {
|
||||
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue