Skip to content

Commit 111b51e

Browse files
committed
C front-end: support inline (and its variants) after asm
GCC supports volatile, inline, goto as asm-qualifiers: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html.
1 parent 1ea6f18 commit 111b51e

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

regression/ansi-c/asm2/main.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
int main()
44
{
55
int x, y;
6-
#ifdef __GNUC__
6+
#ifdef __GNUC__
77
asm goto ("jc %l[error];"
88
: : "r"(x), "r"(&y) : "memory" : error);
9-
#endif
9+
asm __inline volatile("jc %l[error];" : : "r"(x), "r"(&y) : "memory" : error);
10+
#endif
1011
error:
1112
return 0;
1213
}

src/ansi-c/parser.y

+3-4
Original file line numberDiff line numberDiff line change
@@ -2675,10 +2675,9 @@ cprover_exception_statement:
26752675

26762676
volatile_or_goto_opt:
26772677
/* nothing */
2678-
| TOK_VOLATILE
2679-
| TOK_GOTO
2680-
| TOK_GOTO TOK_VOLATILE
2681-
| TOK_VOLATILE TOK_GOTO
2678+
| volatile_or_goto_opt TOK_VOLATILE
2679+
| volatile_or_goto_opt TOK_GOTO
2680+
| volatile_or_goto_opt TOK_INLINE
26822681
;
26832682

26842683
/* asm ( assembler template

src/ansi-c/scanner.l

+3
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,9 @@ __decltype { if(PARSER.cpp98 &&
16391639
"__volatile" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; }
16401640
"__volatile__" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; }
16411641
"goto" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; }
1642+
"inline" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; }
1643+
"__inline" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; }
1644+
"__inline__" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; }
16421645
. { yyless(0); BEGIN(GRAMMAR); loc(); PARSER.asm_block_following=true; return TOK_GCC_ASM; }
16431646
}
16441647

0 commit comments

Comments
 (0)