From cbae1038b9442b45156acce69debc119543c33e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Sat, 4 Jan 2025 15:12:21 +0100 Subject: [PATCH] add test --- test/testunusedfunctions.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/testunusedfunctions.cpp b/test/testunusedfunctions.cpp index a132d51d958..8440f0b88cc 100644 --- a/test/testunusedfunctions.cpp +++ b/test/testunusedfunctions.cpp @@ -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__) @@ -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)