Skip to content

Commit 2844f8e

Browse files
Fix #13225 internalAstError with extra parentheses in loop (danmar#6920)
1 parent 56b7b6a commit 2844f8e

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/tokenlist.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ static bool iscast(const Token *tok, bool cpp)
514514
if (Token::Match(tok->link(), ") }|)|]|;"))
515515
return false;
516516

517+
if (Token::Match(tok->link(), ") ++|-- [;)]"))
518+
return false;
519+
517520
if (Token::Match(tok->link(), ") %cop%") && !Token::Match(tok->link(), ") [&*+-~!]"))
518521
return false;
519522

test/testtokenize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6544,6 +6544,8 @@ class TestTokenizer : public TestFixture {
65446544
" auto l = [x = 3](std::string&& v) { };\n"
65456545
"}\n"));
65466546
ASSERT_EQUALS("[test.cpp:2]: (debug) analyzeConditionExpressions bailout: Skipping function due to incomplete variable x\n", errout_str());
6547+
6548+
ASSERT_EQUALS("forinti(0=i5<=i++;;(", testAst("for (int (i) = 0; (i) <= 5; (i)++) {}")); // #13225
65476549
}
65486550

65496551
void astbrackets() { // []

0 commit comments

Comments
 (0)