File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2575,9 +2575,19 @@ namespace {
25752575}
25762576
25772577static bool
2578- isStaticAssert (const Token *tok)
2578+ isStaticAssert (const Settings &settings, const Token *tok)
25792579{
2580- return Token::Match (tok, " _Static_assert|static_assert (" );
2580+ if (tok->isCpp () && settings.standards .cpp >= Standards::CPP11 &&
2581+ Token::simpleMatch (tok, " static_assert" )) {
2582+ return true ;
2583+ }
2584+
2585+ if (tok->isC () && settings.standards .c >= Standards::C11 &&
2586+ Token::simpleMatch (tok, " _Static_assert" )) {
2587+ return true ;
2588+ }
2589+
2590+ return false ;
25812591}
25822592
25832593void CheckOther::checkDuplicateExpression ()
@@ -2701,12 +2711,12 @@ void CheckOther::checkDuplicateExpression()
27012711 if (assignment)
27022712 selfAssignmentError (tok, tok->astOperand1 ()->expressionString ());
27032713 else if (!isEnum) {
2704- if (tok->isCpp () && mSettings -> standards . cpp >= Standards::CPP11 && tok-> str () == " ==" ) {
2714+ if (tok->str () == " ==" ) {
27052715 const Token* parent = tok->astParent ();
27062716 while (parent && parent->astParent ()) {
27072717 parent = parent->astParent ();
27082718 }
2709- if (parent && isStaticAssert (parent->previous ())) {
2719+ if (parent && parent-> previous () && isStaticAssert (* mSettings , parent->previous ())) {
27102720 continue ;
27112721 }
27122722 }
Original file line number Diff line number Diff line change @@ -6920,7 +6920,7 @@ class TestOther : public TestFixture {
69206920 check (" void f() {\n "
69216921 " enum { Four = 4 };\n "
69226922 " _Static_assert(Four == 4, \"\" );\n "
6923- " }" );
6923+ " }" , false );
69246924 ASSERT_EQUALS (" " , errout_str ());
69256925
69266926 check (" void f() {\n "
You can’t perform that action at this time.
0 commit comments