Skip to content

Commit b067f37

Browse files
Fix #14044 FP constStatement for sizeof in uninstantiated template's argument list (danmar#7716)
Co-authored-by: chrchr-github <[email protected]>
1 parent 2e9b67c commit b067f37

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,7 @@ void CheckOther::checkIncompleteStatement()
22992299
if (!Token::simpleMatch(tok->astParent(), ";") && !Token::simpleMatch(rtok, ";") &&
23002300
!Token::Match(tok->previous(), ";|}|{ %any% ;") &&
23012301
!(tok->isCpp() && tok->isCast() && !tok->astParent()) &&
2302-
!(!tok->astParent() && Token::Match(tok->previous(), "%name% (") && tok->previous()->isKeyword()) &&
2302+
!(!tok->astParent() && tok->astOperand1() && Token::Match(tok->previous(), "%name% (") && tok->previous()->isKeyword()) &&
23032303
!Token::simpleMatch(tok->tokAt(-2), "for (") &&
23042304
!Token::Match(tok->tokAt(-1), "%var% [") &&
23052305
!(tok->str() == "," && tok->astParent() && tok->astParent()->isAssignmentOp()))

test/testincompletestatement.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,11 @@ class TestIncompleteStatement : public TestFixture {
743743
"[test.cpp:4:13]: (warning) Redundant code: Found unused 'noexcept' expression. [constStatement]\n"
744744
"[test.cpp:5:11]: (warning) Redundant code: Found unused 'typeid' expression. [constStatement]\n",
745745
errout_str());
746+
747+
check("void f() {\n" // #14044
748+
" g<sizeof(wchar_t)>();\n"
749+
"}\n");
750+
ASSERT_EQUALS("", errout_str());
746751
}
747752

748753
void vardecl() {

0 commit comments

Comments
 (0)