1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -Wused-but-marked-unused -Wunused-function -Wunneeded-internal-declaration -verify %s 2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s 3*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -Wall %s 4*f4a2713aSLionel Sambuc foo()5*f4a2713aSLionel Sambucvoid foo() {} f2()6*f4a2713aSLionel Sambucstatic void f2() {} f1()7*f4a2713aSLionel Sambucstatic void f1() {f2();} // expected-warning{{unused}} 8*f4a2713aSLionel Sambuc f0()9*f4a2713aSLionel Sambucstatic int f0() { return 17; } // expected-warning{{not needed and will not be emitted}} 10*f4a2713aSLionel Sambuc int x = sizeof(f0()); 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc static void f3(); f3()13*f4a2713aSLionel Sambucextern void f3() { } // expected-warning{{unused}} 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc inline static void f4(); f4()16*f4a2713aSLionel Sambucvoid f4() { } // expected-warning{{unused}} 17*f4a2713aSLionel Sambuc f5()18*f4a2713aSLionel Sambucstatic void __attribute__((used)) f5() {} 19*f4a2713aSLionel Sambuc static void f6(); 20*f4a2713aSLionel Sambuc static void __attribute__((used)) f6(); f6()21*f4a2713aSLionel Sambucstatic void f6() {}; 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc static void f7(void); 24*f4a2713aSLionel Sambuc void f8(void(*a0)(void)); f9(void)25*f4a2713aSLionel Sambucvoid f9(void) { f8(f7); } f7(void)26*f4a2713aSLionel Sambucstatic void f7(void) {} 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc __attribute__((unused)) static void bar(void); bar(void)29*f4a2713aSLionel Sambucvoid bar(void) { } 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambuc __attribute__((constructor)) static void bar2(void); bar2(void)32*f4a2713aSLionel Sambucvoid bar2(void) { } 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc __attribute__((destructor)) static void bar3(void); bar3(void)35*f4a2713aSLionel Sambucvoid bar3(void) { } 36*f4a2713aSLionel Sambuc 37*f4a2713aSLionel Sambuc static void f10(void); // expected-warning{{unused}} 38*f4a2713aSLionel Sambuc static void f10(void); 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc static void f11(void); f11(void)41*f4a2713aSLionel Sambucstatic void f11(void) { } // expected-warning{{unused}} 42*f4a2713aSLionel Sambuc f12(void)43*f4a2713aSLionel Sambucstatic void f12(void) { } // expected-warning{{unused}} 44*f4a2713aSLionel Sambuc static void f12(void); 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc // PR7923 unused(void)47*f4a2713aSLionel Sambucstatic void unused(void) { unused(); } // expected-warning{{not needed and will not be emitted}} 48*f4a2713aSLionel Sambuc 49*f4a2713aSLionel Sambuc // rdar://8728293 cleanupMalloc(char * const * const allocation)50*f4a2713aSLionel Sambucstatic void cleanupMalloc(char * const * const allocation) { } f13(void)51*f4a2713aSLionel Sambucvoid f13(void) { 52*f4a2713aSLionel Sambuc char * const __attribute__((cleanup(cleanupMalloc))) a; 53*f4a2713aSLionel Sambuc (void)a; 54*f4a2713aSLionel Sambuc } 55*f4a2713aSLionel Sambuc 56*f4a2713aSLionel Sambuc // rdar://12233989 57*f4a2713aSLionel Sambuc extern void a(void) __attribute__((unused)); 58*f4a2713aSLionel Sambuc extern void b(void) __attribute__((unused)); 59*f4a2713aSLionel Sambuc b(void)60*f4a2713aSLionel Sambucvoid b(void) 61*f4a2713aSLionel Sambuc { 62*f4a2713aSLionel Sambuc } a(void)63*f4a2713aSLionel Sambucvoid a(void) 64*f4a2713aSLionel Sambuc { 65*f4a2713aSLionel Sambuc b(); 66*f4a2713aSLionel Sambuc } 67