diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 51124c45d1c..ef6fb9003b1 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2408,7 +2408,7 @@ void CheckOtherImpl::checkIncompleteStatement() !(tok->str() == "," && tok->astParent() && tok->astParent()->isAssignmentOp())) continue; // Skip statement expressions - if (Token::simpleMatch(rtok, "; } )")) + if (Token::simpleMatch(rtok, "; } )") || Token::simpleMatch(tok->next(), "; } )")) continue; if (!isConstStatement(tok, mSettings.library, false)) continue; diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index b72b6524872..806f734274e 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -758,6 +758,11 @@ class TestIncompleteStatement : public TestFixture { "}\n"); ASSERT_EQUALS("[test.cpp:4:6]: (warning) Redundant code: Found unused array access. [constStatement]\n", errout_str()); + + check("int f(int i) {\n" // #14889 + " return i ? 8 : ({ int x = 2; x; });\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void vardecl() {