Skip to content

Commit cd75b2d

Browse files
committed
AST: fix hang for code 'MACRO({.x=1,.y=2})'
1 parent 67ea470 commit cd75b2d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/tokenlist.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,8 @@ static Token * createAstAtToken(Token *tok, bool cpp)
895895
continue;
896896
if (tok->next() == endToken)
897897
break;
898+
if (Token::simpleMatch(tok, "( { ."))
899+
break;
898900
const Token * const endToken2 = tok->linkAt(1);
899901
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : NULL)
900902
tok = createAstAtToken(tok, cpp);

test/testtokenize.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10755,6 +10755,9 @@ class TestTokenizer : public TestFixture {
1075510755
ASSERT_EQUALS("QT_WA{{,( QT_WA{{,( x1=",
1075610756
testAst("QT_WA({},{x=0;});" // don't hang
1075710757
"QT_WA({x=1;},{x=2;});"));
10758+
ASSERT_EQUALS("xMACROtypeT=value1=,{({=",
10759+
testAst("x = { MACRO( { .type=T, .value=1 } ) }")); // dont hang: MACRO({..})
10760+
1075810761

1075910762
// function pointer
1076010763
TODO_ASSERT_EQUALS("todo", "va_argapvoid((,(*0=", testAst("*va_arg(ap, void(**) ()) = 0;"));

0 commit comments

Comments
 (0)