Skip to content

Commit

Permalink
Permit asm post-declarator mixed in any order with other qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Jun 11, 2018
1 parent fde09ca commit d82f554
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/cpp/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2001,7 +2001,7 @@ bool Parser::optCvQualify(typet &cv)
if(t==TOK_CONSTEXPR ||
t==TOK_CONST || t==TOK_VOLATILE || t==TOK_RESTRICT ||
t==TOK_PTR32 || t==TOK_PTR64 ||
t==TOK_GCC_ATTRIBUTE)
t==TOK_GCC_ATTRIBUTE || t==TOK_GCC_ASM)
{
cpp_tokent tk;
lex.get_token(tk);
Expand Down Expand Up @@ -2050,6 +2050,18 @@ bool Parser::optCvQualify(typet &cv)
return false;
break;

case TOK_GCC_ASM:
// asm post-declarator
// this is stuff like
// int x __asm("asd")=1, y;
if(lex.get_token(tk)!='(')
return false;
if(!rString(tk))
return false;
if(lex.get_token(tk)!=')')
return false;
break;

default:
UNREACHABLE;
break;
Expand Down Expand Up @@ -2816,22 +2828,6 @@ bool Parser::rDeclaratorWithInit(
should_be_declarator, is_statement))
return false;

// asm post-declarator
if(lex.LookAhead(0)==TOK_GCC_ASM)
{
// this is stuff like
// int x __asm("asd")=1, y;
cpp_tokent tk;
lex.get_token(tk); // TOK_GCC_ASM

if(lex.get_token(tk)!='(')
return false;
if(!rString(tk))
return false;
if(lex.get_token(tk)!=')')
return false;
}

int t=lex.LookAhead(0);
if(t=='=')
{
Expand Down

0 comments on commit d82f554

Please sign in to comment.