Skip to content

Commit d82f554

Browse files
committed
Permit asm post-declarator mixed in any order with other qualifiers
1 parent fde09ca commit d82f554

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

src/cpp/parse.cpp

+13-17
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ bool Parser::optCvQualify(typet &cv)
20012001
if(t==TOK_CONSTEXPR ||
20022002
t==TOK_CONST || t==TOK_VOLATILE || t==TOK_RESTRICT ||
20032003
t==TOK_PTR32 || t==TOK_PTR64 ||
2004-
t==TOK_GCC_ATTRIBUTE)
2004+
t==TOK_GCC_ATTRIBUTE || t==TOK_GCC_ASM)
20052005
{
20062006
cpp_tokent tk;
20072007
lex.get_token(tk);
@@ -2050,6 +2050,18 @@ bool Parser::optCvQualify(typet &cv)
20502050
return false;
20512051
break;
20522052

2053+
case TOK_GCC_ASM:
2054+
// asm post-declarator
2055+
// this is stuff like
2056+
// int x __asm("asd")=1, y;
2057+
if(lex.get_token(tk)!='(')
2058+
return false;
2059+
if(!rString(tk))
2060+
return false;
2061+
if(lex.get_token(tk)!=')')
2062+
return false;
2063+
break;
2064+
20532065
default:
20542066
UNREACHABLE;
20552067
break;
@@ -2816,22 +2828,6 @@ bool Parser::rDeclaratorWithInit(
28162828
should_be_declarator, is_statement))
28172829
return false;
28182830

2819-
// asm post-declarator
2820-
if(lex.LookAhead(0)==TOK_GCC_ASM)
2821-
{
2822-
// this is stuff like
2823-
// int x __asm("asd")=1, y;
2824-
cpp_tokent tk;
2825-
lex.get_token(tk); // TOK_GCC_ASM
2826-
2827-
if(lex.get_token(tk)!='(')
2828-
return false;
2829-
if(!rString(tk))
2830-
return false;
2831-
if(lex.get_token(tk)!=')')
2832-
return false;
2833-
}
2834-
28352831
int t=lex.LookAhead(0);
28362832
if(t=='=')
28372833
{

0 commit comments

Comments
 (0)