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