Fix 9740: FP accessMoved related to designated initialization (#3644)

This commit is contained in:
Paul Fultz II 2021-12-19 05:36:48 -06:00 committed by GitHub
parent cc24d6fcef
commit d69257e8cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -803,7 +803,14 @@ static void compileTerm(Token *&tok, AST_state& state)
if (state.op.empty() || Token::Match(tok->previous(), "[{,]") || Token::Match(tok->tokAt(-2), "%name% (")) {
if (Token::Match(tok, "{ !!}")) {
Token *const end = tok->link();
compileUnaryOp(tok, state, compileExpression);
if (Token::Match(tok, "{ . %name% =|{")) {
const int inArrayAssignment = state.inArrayAssignment;
state.inArrayAssignment = 1;
compileBinOp(tok, state, compileExpression);
state.inArrayAssignment = inArrayAssignment;
} else {
compileUnaryOp(tok, state, compileExpression);
}
if (precedes(tok,end))
tok = end;
} else {

View File

@ -6107,6 +6107,7 @@ private:
ASSERT_EQUALS("a0{,( \"\"abc12:?,", testAst("a(0, {{\"\", (abc) ? 1 : 2}});"));
ASSERT_EQUALS("a0{,( \'\'abc12:?,", testAst("a(0, {{\'\', (abc) ? 1 : 2}});"));
ASSERT_EQUALS("x12,{34,{,{56,{78,{,{,{=", testAst("x = { { {1,2}, {3,4} }, { {5,6}, {7,8} } };"));
ASSERT_EQUALS("Sa.stdmove::s(=b.1=,{(", testAst("S({.a = std::move(s), .b = 1})"));
// struct initialization hang
ASSERT_EQUALS("sbar.1{,{(={= forfieldfield++;;(",