diff --git a/lib/token.cpp b/lib/token.cpp index 90f16b637..b28498b29 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -1341,7 +1341,7 @@ std::pair Token::findExpressionStartEndTokens() co break; } } - if (Token::Match(end,"(|[") && + if (Token::Match(end,"(|[|{") && !(Token::Match(end, "( %type%") && !end->astOperand2())) { end = end->link(); break; diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index fd3e5f09e..3340b7df2 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -994,7 +994,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state) castTok->isCast(true); tok = tok->link()->next(); const int inArrayAssignment = state.inArrayAssignment; - if (Token::Match(tok, "{ . %name% =")) + if (tok && tok->str() == "{") state.inArrayAssignment = 1; compilePrecedence3(tok, state); state.inArrayAssignment = inArrayAssignment; diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 87ba2d28b..27f7573a0 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -2402,9 +2402,8 @@ private: "struct bstr bstr0 ( const char * s ) { " "return ( struct bstr ) { ( unsigned char * ) s , s ? strlen ( s ) : 0 } ; " "}"; - TODO_ASSERT_THROW(tok(code, false), InternalError); // TODO: Do not produce bad AST - //ASSERT_EQUALS(expected, tok(code, false)); - //ASSERT_EQUALS("", errout.str()); + ASSERT_EQUALS(expected, tok(code, false)); + ASSERT_EQUALS("", errout.str()); } void simplifyTypedef118() { // #5749