File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2574,6 +2574,12 @@ namespace {
25742574 }
25752575}
25762576
2577+ static bool
2578+ isStaticAssert (const Token *tok)
2579+ {
2580+ return Token::Match (tok, " _Static_assert|static_assert (" );
2581+ }
2582+
25772583void CheckOther::checkDuplicateExpression ()
25782584{
25792585 {
@@ -2700,7 +2706,7 @@ void CheckOther::checkDuplicateExpression()
27002706 while (parent && parent->astParent ()) {
27012707 parent = parent->astParent ();
27022708 }
2703- if (parent && parent->previous () && parent-> strAt (- 1 ) == " static_assert " ) {
2709+ if (parent && isStaticAssert ( parent->previous ()) ) {
27042710 continue ;
27052711 }
27062712 }
Original file line number Diff line number Diff line change @@ -6917,6 +6917,12 @@ class TestOther : public TestFixture {
69176917 " }" );
69186918 ASSERT_EQUALS (" " , errout_str ());
69196919
6920+ check (" void f() {\n "
6921+ " enum { Four = 4 };\n "
6922+ " _Static_assert(Four == 4, \"\" );\n "
6923+ " }" );
6924+ ASSERT_EQUALS (" " , errout_str ());
6925+
69206926 check (" void f() {\n "
69216927 " enum { Four = 4 };\n "
69226928 " static_assert(4 == Four, \"\" );\n "
You can’t perform that action at this time.
0 commit comments