Skip to content

Commit 303b3aa

Browse files
authored
Merge pull request #6545 from tautschnig/asm-line-markers
C front-end: support preprocessor line markers in inline asm
2 parents 95d8c91 + c7da320 commit 303b3aa

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

regression/ansi-c/asm2/main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ int main()
66
#ifdef __GNUC__
77
asm goto ("jc %l[error];"
88
: : "r"(x), "r"(&y) : "memory" : error);
9-
asm __inline volatile("jc %l[error];" : : "r"(x), "r"(&y) : "memory" : error);
9+
asm
10+
# 11
11+
__inline volatile("jc %l[error];"
12+
:
13+
: "r"(x), "r"(&y)
14+
: "memory"
15+
: error);
1016
#endif
1117
error:
1218
return 0;

src/ansi-c/scanner.l

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,10 @@ __decltype { if(PARSER.cpp98 &&
16371637
/* The following ugly stuff avoids two-token lookahead in the parser;
16381638
e.g., asm void f() vs. asm ("xyz") or asm { ... } */
16391639
<GCC_ASM>{
1640+
{cpplineno} {
1641+
preprocessor_line(yytext, PARSER);
1642+
PARSER.set_line_no(PARSER.get_line_no()-1);
1643+
}
16401644
{ws} { /* ignore */ }
16411645
{newline} { /* ignore */ }
16421646
"{" { yyless(0); BEGIN(GRAMMAR); loc(); PARSER.asm_block_following=true; return TOK_GCC_ASM_PAREN; }

0 commit comments

Comments
 (0)