Skip to content

Commit ccbde01

Browse files
Fix #15020 FP knownConditionTrueFalse in C23 static_assert (#8841)
1 parent c193dfd commit ccbde01

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

lib/checkother.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,9 +2927,11 @@ isStaticAssert(const Settings &settings, const Token *tok)
29272927
return true;
29282928
}
29292929

2930-
if (tok->isC() && settings.standards.c >= Standards::C11 &&
2931-
Token::simpleMatch(tok, "_Static_assert")) {
2932-
return true;
2930+
if (tok->isC()) {
2931+
if (settings.standards.c >= Standards::C11 && Token::simpleMatch(tok, "_Static_assert"))
2932+
return true;
2933+
if (settings.standards.c >= Standards::C23 && Token::simpleMatch(tok, "static_assert"))
2934+
return true;
29332935
}
29342936

29352937
return false;

test/testother.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7756,6 +7756,12 @@ class TestOther : public TestFixture {
77567756
"}\n", dinit(CheckOptions, $.cpp = false));
77577757
ASSERT_EQUALS("", errout_str());
77587758

7759+
check("void f() {\n" // #15020
7760+
" enum { Four = 4 };\n"
7761+
" static_assert(Four == 4, \"\");\n"
7762+
"}\n", dinit(CheckOptions, $.cpp = false));
7763+
ASSERT_EQUALS("", errout_str());
7764+
77597765
check("void f() {\n"
77607766
" enum { Four = 4 };\n"
77617767
" static_assert(4 == Four, \"\");\n"

0 commit comments

Comments
 (0)