1 // RUN: %clang_cc1 -fsyntax-only -Wunused -std=c2x -verify %s
3 // This is the latest version of maybe_unused that we support.
4 _Static_assert(__has_c_attribute(maybe_unused
) == 202106L);
6 struct [[maybe_unused
]] S1
{ // ok
7 int a
[[maybe_unused
]];
10 enum [[maybe_unused
]] E1
{
11 EnumVal
[[maybe_unused
]]
14 [[maybe_unused
]] void unused_func([[maybe_unused
]] int parm
) {
15 typedef int maybe_unused_int
[[maybe_unused
]];
16 [[maybe_unused
]] int I
;
20 int x
; // expected-warning {{unused variable}}
21 typedef int I
; // expected-warning {{unused typedef 'I'}}
23 // Should not warn about these due to not being used.
24 [[maybe_unused
]] int y
;
25 typedef int maybe_unused_int
[[maybe_unused
]];
27 // Should not warn about these uses.
29 maybe_unused_int test
;
34 [[maybe_unused
]] void f2(void);
40 [[maybe_unused
]] label
:
43 other_label
: // expected-warning {{unused label 'other_label'}}