From 1dd19dcaefd9af6aec171f14d9f8c65adc7ce007 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 26 Mar 2022 22:39:14 +0100 Subject: [PATCH] Fix AST cyclic dependency [cppcheckError] (#3945) --- lib/tokenlist.cpp | 2 +- test/testtokenize.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 8a81231e8..02f4cd95c 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -814,7 +814,7 @@ static void compileTerm(Token *&tok, AST_state& state) state.op.push(tok); if (Token::Match(tok, "%name% <") && tok->linkAt(1)) tok = tok->linkAt(1); - else if (Token::Match(tok, "%name% ...") || (state.op.size() == 1 && Token::Match(tok->tokAt(-2), ") ( %name% ) ="))) + else if (Token::Match(tok, "%name% ...") || (state.op.size() == 1 && state.depth == 0 && Token::Match(tok->tokAt(-2), ") ( %name% ) ="))) tok = tok->next(); tok = tok->next(); if (Token::Match(tok, "%str%")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7aeaa5412..3e531ab55 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6220,6 +6220,7 @@ private: "}\n")); ASSERT_EQUALS("x0=a, stdtie::a(x=", testAst("int x = 0, a; std::tie(a) = x;\n")); ASSERT_EQUALS("tmpa*=a*b*=,b*tmp=,", testAst("{ ((tmp) = (*a)), ((*a) = (*b)), ((*b) = (tmp)); }")); + ASSERT_EQUALS("a(*v=", testAst("(*(volatile unsigned int *)(a) = (v));")); } void astunaryop() { // unary operators