File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -1342,11 +1342,11 @@ void CheckClass::privateFunctions()
13421342
13431343 while (!privateFuncs.empty ()) {
13441344 const auto & pf = privateFuncs.front ();
1345- if (pf->token ->isAttributeMaybeUnused ()) {
1345+ if (pf->token ->isAttributeMaybeUnused () || pf-> token -> isAttributeUnused () ) {
13461346 privateFuncs.pop_front ();
13471347 continue ;
13481348 }
1349- if (pf->tokenDef && pf->tokenDef ->isAttributeMaybeUnused ()) {
1349+ if (pf->tokenDef && ( pf->tokenDef ->isAttributeMaybeUnused () || pf-> tokenDef -> isAttributeUnused () )) {
13501350 privateFuncs.pop_front ();
13511351 continue ;
13521352 }
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ class TestUnusedPrivateFunction : public TestFixture {
8484
8585 TEST_CASE (templateSimplification); // ticket #6183
8686 TEST_CASE (maybeUnused);
87+ TEST_CASE (attributeUnused); // #14129
8788 TEST_CASE (trailingReturn);
8889 }
8990
@@ -890,6 +891,19 @@ class TestUnusedPrivateFunction : public TestFixture {
890891 ASSERT_EQUALS (" " , errout_str ());
891892 }
892893
894+ void attributeUnused () {
895+ check (" class C {\n "
896+ " __attribute__((unused)) int f() { return 42; }\n "
897+ " };" );
898+ ASSERT_EQUALS (" " , errout_str ());
899+
900+ check (" class C {\n "
901+ " __attribute__((unused)) int f();\n "
902+ " };\n "
903+ " int C::f() { return 42; }\n " );
904+ ASSERT_EQUALS (" " , errout_str ());
905+ }
906+
893907 void trailingReturn () {
894908 check (" struct B { virtual void f(); };\n "
895909 " struct D : B {\n "
You can’t perform that action at this time.
0 commit comments