From 657f13b7a0d6fc5d61f6b58a845e45dac0b12660 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Mon, 4 Aug 2025 18:54:42 +0200 Subject: [PATCH 1/2] Fix #14044 FP constStatement for sizeof in uninstantiated template's argument list --- lib/checkother.cpp | 2 +- test/testincompletestatement.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index de39f5bdcda..5af22c7b2c5 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2299,7 +2299,7 @@ void CheckOther::checkIncompleteStatement() if (!Token::simpleMatch(tok->astParent(), ";") && !Token::simpleMatch(rtok, ";") && !Token::Match(tok->previous(), ";|}|{ %any% ;") && !(tok->isCpp() && tok->isCast() && !tok->astParent()) && - !(!tok->astParent() && Token::Match(tok->previous(), "%name% (") && tok->previous()->isKeyword()) && + !(!tok->astParent() && tok->astOperand1() && Token::Match(tok->previous(), "%name% (") && tok->previous()->isKeyword()) && !Token::simpleMatch(tok->tokAt(-2), "for (") && !Token::Match(tok->tokAt(-1), "%var% [") && !(tok->str() == "," && tok->astParent() && tok->astParent()->isAssignmentOp())) diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index afdacb77c51..6fb1e04b164 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -743,6 +743,11 @@ class TestIncompleteStatement : public TestFixture { "[test.cpp:4:13]: (warning) Redundant code: Found unused 'noexcept' expression. [constStatement]\n" "[test.cpp:5:11]: (warning) Redundant code: Found unused 'typeid' expression. [constStatement]\n", errout_str()); + + check("void f() {\n" // #14044 + " g();\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void vardecl() { From a99d0e2c641f424e81b31f4570c62445f5f50a30 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Mon, 4 Aug 2025 18:56:40 +0200 Subject: [PATCH 2/2] Format --- test/testincompletestatement.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index 6fb1e04b164..f1694ea262f 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -745,7 +745,7 @@ class TestIncompleteStatement : public TestFixture { errout_str()); check("void f() {\n" // #14044 - " g();\n" + " g();\n" "}\n"); ASSERT_EQUALS("", errout_str()); }