Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ludviggunne committed Jan 4, 2025
1 parent 445bc7a commit cbae103
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/testunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class TestUnusedFunctions : public TestFixture {
TEST_CASE(parensInit);
TEST_CASE(typeInCast);
TEST_CASE(attributeCleanup);
TEST_CASE(attributeUnused);
TEST_CASE(attributeMaybeUnused);
}

#define check(...) check_(__FILE__, __LINE__, __VA_ARGS__)
Expand Down Expand Up @@ -794,6 +796,27 @@ class TestUnusedFunctions : public TestFixture {
"}\n");
ASSERT_EQUALS("", errout_str());
}

void attributeUnused()
{
check("[[unused]] void f() {}\n");
ASSERT_EQUALS("", errout_str());

check("[[gnu::unused]] void f() {}\n");
ASSERT_EQUALS("", errout_str());

check("__attribute__((unused)) void f() {}\n");
ASSERT_EQUALS("", errout_str());
}

void attributeMaybeUnused()
{
check("[[__maybe_unused__]] void f() {}\n");
ASSERT_EQUALS("", errout_str());

check("[[maybe_unused]] void f() {}\n");
ASSERT_EQUALS("", errout_str());
}
};

REGISTER_TEST(TestUnusedFunctions)

0 comments on commit cbae103

Please sign in to comment.