[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / c2x-maybe_unused.c
blob82b9634fc9f39ea5aebafc9de4c26f21fea676c2
1 // RUN: %clang_cc1 -fsyntax-only -Wunused -std=c2x -verify %s
3 struct [[maybe_unused]] S1 { // ok
4 int a [[maybe_unused]];
5 };
7 enum [[maybe_unused]] E1 {
8 EnumVal [[maybe_unused]]
9 };
11 [[maybe_unused]] void unused_func([[maybe_unused]] int parm) {
12 typedef int maybe_unused_int [[maybe_unused]];
13 [[maybe_unused]] int I;
16 void f1(void) {
17 int x; // expected-warning {{unused variable}}
18 typedef int I; // expected-warning {{unused typedef 'I'}}
20 // Should not warn about these due to not being used.
21 [[maybe_unused]] int y;
22 typedef int maybe_unused_int [[maybe_unused]];
24 // Should not warn about these uses.
25 struct S1 s;
26 maybe_unused_int test;
27 y = 12;
30 void f2(void);
31 [[maybe_unused]] void f2(void);
33 void f2(void) {