Skip to content

Commit e7e54f7

Browse files
Fix #14889 FP constStatement with GNU statement expression (#8698)
1 parent 42a0805 commit e7e54f7

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2408,7 +2408,7 @@ void CheckOtherImpl::checkIncompleteStatement()
24082408
!(tok->str() == "," && tok->astParent() && tok->astParent()->isAssignmentOp()))
24092409
continue;
24102410
// Skip statement expressions
2411-
if (Token::simpleMatch(rtok, "; } )"))
2411+
if (Token::simpleMatch(rtok, "; } )") || Token::simpleMatch(tok->next(), "; } )"))
24122412
continue;
24132413
if (!isConstStatement(tok, mSettings.library, false))
24142414
continue;

test/testincompletestatement.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,11 @@ class TestIncompleteStatement : public TestFixture {
758758
"}\n");
759759
ASSERT_EQUALS("[test.cpp:4:6]: (warning) Redundant code: Found unused array access. [constStatement]\n",
760760
errout_str());
761+
762+
check("int f(int i) {\n" // #14889
763+
" return i ? 8 : ({ int x = 2; x; });\n"
764+
"}\n");
765+
ASSERT_EQUALS("", errout_str());
761766
}
762767

763768
void vardecl() {

0 commit comments

Comments
 (0)