Skip to content

Commit 1008868

Browse files
committed
AST: Better handling of '(type){..}'
1 parent 4091415 commit 1008868

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

lib/token.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ std::pair<const Token *, const Token *> Token::findExpressionStartEndTokens() co
13411341
break;
13421342
}
13431343
}
1344-
if (Token::Match(end,"(|[") &&
1344+
if (Token::Match(end,"(|[|{") &&
13451345
!(Token::Match(end, "( %type%") && !end->astOperand2())) {
13461346
end = end->link();
13471347
break;

lib/tokenlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
994994
castTok->isCast(true);
995995
tok = tok->link()->next();
996996
const int inArrayAssignment = state.inArrayAssignment;
997-
if (Token::Match(tok, "{ . %name% ="))
997+
if (tok && tok->str() == "{")
998998
state.inArrayAssignment = 1;
999999
compilePrecedence3(tok, state);
10001000
state.inArrayAssignment = inArrayAssignment;

test/testsimplifytypedef.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,9 +2402,8 @@ class TestSimplifyTypedef : public TestFixture {
24022402
"struct bstr bstr0 ( const char * s ) { "
24032403
"return ( struct bstr ) { ( unsigned char * ) s , s ? strlen ( s ) : 0 } ; "
24042404
"}";
2405-
TODO_ASSERT_THROW(tok(code, false), InternalError); // TODO: Do not produce bad AST
2406-
//ASSERT_EQUALS(expected, tok(code, false));
2407-
//ASSERT_EQUALS("", errout.str());
2405+
ASSERT_EQUALS(expected, tok(code, false));
2406+
ASSERT_EQUALS("", errout.str());
24082407
}
24092408

24102409
void simplifyTypedef118() { // #5749

0 commit comments

Comments
 (0)