46 lines · c
1// RUN: %clang_cc1 -fsyntax-only -Wunused -std=c2x -verify %s2 3// This is the latest version of maybe_unused that we support.4_Static_assert(__has_c_attribute(maybe_unused) == 202106L);5 6struct [[maybe_unused]] S1 { // ok7 int a [[maybe_unused]];8};9 10enum [[maybe_unused]] E1 {11 EnumVal [[maybe_unused]]12};13 14[[maybe_unused]] void unused_func([[maybe_unused]] int parm) {15 typedef int maybe_unused_int [[maybe_unused]];16 [[maybe_unused]] int I;17}18 19void f1(void) {20 int x; // expected-warning {{unused variable}}21 typedef int I; // expected-warning {{unused typedef 'I'}}22 23 // Should not warn about these due to not being used.24 [[maybe_unused]] int y;25 typedef int maybe_unused_int [[maybe_unused]];26 27 // Should not warn about these uses.28 struct S1 s;29 maybe_unused_int test;30 y = 12;31}32 33void f2(void);34[[maybe_unused]] void f2(void);35 36void f2(void) {37}38 39void label(void) {40 [[maybe_unused]] label:41 ;42 43 other_label: // expected-warning {{unused label 'other_label'}}44 ;45}46