[NFC][RISCV] Remove CFIIndex argument from allocateStack (#117871)
[llvm-project.git] / clang / test / Sema / c2x-maybe_unused.c
blobf531521227d7f5a6682e98cf1fab5b4f185e3e48
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]];
8 };
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;
19 void f1(void) {
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.
28 struct S1 s;
29 maybe_unused_int test;
30 y = 12;
33 void f2(void);
34 [[maybe_unused]] void f2(void);
36 void f2(void) {
39 void label(void) {
40 [[maybe_unused]] label:
43 other_label: // expected-warning {{unused label 'other_label'}}