AST: Better handling of '(type){..}'

This commit is contained in:
Daniel Marjamäki 2020-03-08 16:45:51 +01:00
parent 40914159a8
commit 1008868506
3 changed files with 4 additions and 5 deletions

View File

@ -1341,7 +1341,7 @@ std::pair<const Token *, const Token *> Token::findExpressionStartEndTokens() co
break; break;
} }
} }
if (Token::Match(end,"(|[") && if (Token::Match(end,"(|[|{") &&
!(Token::Match(end, "( %type%") && !end->astOperand2())) { !(Token::Match(end, "( %type%") && !end->astOperand2())) {
end = end->link(); end = end->link();
break; break;

View File

@ -994,7 +994,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
castTok->isCast(true); castTok->isCast(true);
tok = tok->link()->next(); tok = tok->link()->next();
const int inArrayAssignment = state.inArrayAssignment; const int inArrayAssignment = state.inArrayAssignment;
if (Token::Match(tok, "{ . %name% =")) if (tok && tok->str() == "{")
state.inArrayAssignment = 1; state.inArrayAssignment = 1;
compilePrecedence3(tok, state); compilePrecedence3(tok, state);
state.inArrayAssignment = inArrayAssignment; state.inArrayAssignment = inArrayAssignment;

View File

@ -2402,9 +2402,8 @@ private:
"struct bstr bstr0 ( const char * s ) { " "struct bstr bstr0 ( const char * s ) { "
"return ( struct bstr ) { ( unsigned char * ) s , s ? strlen ( s ) : 0 } ; " "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(expected, tok(code, false)); ASSERT_EQUALS("", errout.str());
//ASSERT_EQUALS("", errout.str());
} }
void simplifyTypedef118() { // #5749 void simplifyTypedef118() { // #5749