1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc static void (*fp0)(void) __attribute__((unused)); 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc static void __attribute__((unused)) f0(void); 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc // On K&R 8*f4a2713aSLionel Sambuc int f1() __attribute__((unused)); 9*f4a2713aSLionel Sambuc 10*f4a2713aSLionel Sambuc int g0 __attribute__((unused)); 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc int f2() __attribute__((unused(1, 2))); // expected-error {{'unused' attribute takes no arguments}} 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc struct Test0_unused {} __attribute__((unused)); 15*f4a2713aSLionel Sambuc struct Test0_not_unused {}; 16*f4a2713aSLionel Sambuc typedef int Int_unused __attribute__((unused)); 17*f4a2713aSLionel Sambuc typedef int Int_not_unused; 18*f4a2713aSLionel Sambuc test0()19*f4a2713aSLionel Sambucvoid test0() { 20*f4a2713aSLionel Sambuc int x; // expected-warning {{unused variable}} 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc Int_not_unused i0; // expected-warning {{unused variable}} 23*f4a2713aSLionel Sambuc Int_unused i1; // expected-warning {{'Int_unused' was marked unused but was used}} 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc struct Test0_not_unused s0; // expected-warning {{unused variable}} 26*f4a2713aSLionel Sambuc struct Test0_unused s1; // expected-warning {{'Test0_unused' was marked unused but was used}} 27*f4a2713aSLionel Sambuc } 28*f4a2713aSLionel Sambuc f3(int x)29*f4a2713aSLionel Sambucint f3(int x) { // expected-warning{{unused parameter 'x'}} 30*f4a2713aSLionel Sambuc return 0; 31*f4a2713aSLionel Sambuc } 32*f4a2713aSLionel Sambuc f4(int x)33*f4a2713aSLionel Sambucint f4(int x) { 34*f4a2713aSLionel Sambuc return x; 35*f4a2713aSLionel Sambuc } 36*f4a2713aSLionel Sambuc f5(int x)37*f4a2713aSLionel Sambucint f5(int x __attribute__((__unused__))) { 38*f4a2713aSLionel Sambuc return 0; 39*f4a2713aSLionel Sambuc } 40*f4a2713aSLionel Sambuc f6(int x)41*f4a2713aSLionel Sambucint f6(int x __attribute__((__unused__))) { 42*f4a2713aSLionel Sambuc return x; // expected-warning{{'x' was marked unused but was used}} 43*f4a2713aSLionel Sambuc } 44