Skip to content

Commit 270518c

Browse files
Fix #12815 Crash in singleAssignInScope() (#6489)
1 parent e0ce648 commit 270518c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Diff for: lib/tokenlist.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,10 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
960960
tok = tok->tokAt(3);
961961
break;
962962
}
963-
compileBinOp(tok, state, compileScope);
963+
if (!Token::Match(tok->tokAt(-1), "[{,]"))
964+
compileBinOp(tok, state, compileScope);
965+
else
966+
compileUnaryOp(tok, state, compileScope);
964967
} else if (tok->str() == "[") {
965968
if (state.cpp && isPrefixUnary(tok, /*cpp*/ true) && Token::Match(tok->link(), "] (|{|<")) { // Lambda
966969
// What we do here:

Diff for: test/testtokenize.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -6634,7 +6634,9 @@ class TestTokenizer : public TestFixture {
66346634
ASSERT_EQUALS("double&(4[", testAst("void f(double(&)[4]) {}"));
66356635
ASSERT_EQUALS("voidu*", testAst("int* g ( void* (f) (void*), void* u);")); // #12475
66366636
ASSERT_EQUALS("f::(", testAst("::f();")); // #12544
6637-
ASSERT_EQUALS("(( (, f ({ (= (. c x) 0))))", testAst("f(c, { .x = 0 });", AstStyle::Z3)); // #12806
6637+
ASSERT_EQUALS("(( f (, c ({ (= (. x) 0))))", testAst("f(c, { .x = 0 });", AstStyle::Z3)); // #12806
6638+
ASSERT_EQUALS("(= it (( (. s insert) (, it ({ (, (, (= (. a) i) (= (. b) 2)) (= (. c) 3))))))",
6639+
testAst("it = s.insert(it, { .a = i, .b = 2, .c = 3 });", AstStyle::Z3)); // #12815
66386640
}
66396641

66406642
void asttemplate() { // uninstantiated templates will have <,>,etc..

0 commit comments

Comments
 (0)