From 111b51e6410a164c1377513a6641d4dc996b8f4f Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 15 Mar 2021 09:42:39 +0000 Subject: [PATCH] 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. --- regression/ansi-c/asm2/main.c | 5 +++-- src/ansi-c/parser.y | 7 +++---- src/ansi-c/scanner.l | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/regression/ansi-c/asm2/main.c b/regression/ansi-c/asm2/main.c index 30d401544a9..d80e90bb0a6 100644 --- a/regression/ansi-c/asm2/main.c +++ b/regression/ansi-c/asm2/main.c @@ -3,10 +3,11 @@ int main() { int x, y; - #ifdef __GNUC__ +#ifdef __GNUC__ asm goto ("jc %l[error];" : : "r"(x), "r"(&y) : "memory" : error); - #endif + asm __inline volatile("jc %l[error];" : : "r"(x), "r"(&y) : "memory" : error); +#endif error: return 0; } diff --git a/src/ansi-c/parser.y b/src/ansi-c/parser.y index 959a545a91b..b719b1a488f 100644 --- a/src/ansi-c/parser.y +++ b/src/ansi-c/parser.y @@ -2675,10 +2675,9 @@ cprover_exception_statement: volatile_or_goto_opt: /* nothing */ - | TOK_VOLATILE - | TOK_GOTO - | TOK_GOTO TOK_VOLATILE - | TOK_VOLATILE TOK_GOTO + | volatile_or_goto_opt TOK_VOLATILE + | volatile_or_goto_opt TOK_GOTO + | volatile_or_goto_opt TOK_INLINE ; /* asm ( assembler template diff --git a/src/ansi-c/scanner.l b/src/ansi-c/scanner.l index 7308f90d811..f7d23af3f1f 100644 --- a/src/ansi-c/scanner.l +++ b/src/ansi-c/scanner.l @@ -1639,6 +1639,9 @@ __decltype { if(PARSER.cpp98 && "__volatile" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } "__volatile__" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } "goto" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } +"inline" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } +"__inline" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } +"__inline__" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } . { yyless(0); BEGIN(GRAMMAR); loc(); PARSER.asm_block_following=true; return TOK_GCC_ASM; } }