Fariborz Jahanian | 2d40d9e | 2012-09-06 16:43:18 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -Wused-but-marked-unused -Wunused-function -Wunneeded-internal-declaration -verify %s |
Ted Kremenek | e1fcf29 | 2010-04-08 17:54:28 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -verify -Wall %s |
Tanya Lattner | e6bbc01 | 2010-02-12 00:07:30 +0000 | [diff] [blame] | 4 | |
| 5 | void foo() {} |
| 6 | static void f2() {} |
| 7 | static void f1() {f2();} // expected-warning{{unused}} |
| 8 | |
Argyrios Kyrtzidis | 6b6b42a | 2011-04-19 19:51:10 +0000 | [diff] [blame] | 9 | static int f0() { return 17; } // expected-warning{{not needed and will not be emitted}} |
Tanya Lattner | e6bbc01 | 2010-02-12 00:07:30 +0000 | [diff] [blame] | 10 | int x = sizeof(f0()); |
| 11 | |
| 12 | static void f3(); |
| 13 | extern void f3() { } // expected-warning{{unused}} |
| 14 | |
Bill Wendling | 251b18d | 2013-10-17 04:13:35 +0000 | [diff] [blame] | 15 | inline static void f4(); |
| 16 | void f4() { } // expected-warning{{unused}} |
Tanya Lattner | 12ead49 | 2010-02-17 02:17:21 +0000 | [diff] [blame] | 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) {} |
Tanya Lattner | c777221 | 2010-02-17 04:48:01 +0000 | [diff] [blame] | 27 | |
| 28 | __attribute__((unused)) static void bar(void); |
| 29 | void bar(void) { } |
| 30 | |
Chris Lattner | 1a4221c | 2010-04-09 17:25:05 +0000 | [diff] [blame] | 31 | __attribute__((constructor)) static void bar2(void); |
| 32 | void bar2(void) { } |
| 33 | |
| 34 | __attribute__((destructor)) static void bar3(void); |
| 35 | void bar3(void) { } |
Argyrios Kyrtzidis | bbc6454 | 2010-08-15 01:15:20 +0000 | [diff] [blame] | 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); |
Argyrios Kyrtzidis | 58b5259 | 2010-08-25 10:34:54 +0000 | [diff] [blame] | 45 | |
| 46 | // PR7923 |
Argyrios Kyrtzidis | 6b6b42a | 2011-04-19 19:51:10 +0000 | [diff] [blame] | 47 | static void unused(void) { unused(); } // expected-warning{{not needed and will not be emitted}} |
Argyrios Kyrtzidis | ae3038c | 2010-12-04 01:12:11 +0000 | [diff] [blame] | 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 | } |
Fariborz Jahanian | 2d40d9e | 2012-09-06 16:43:18 +0000 | [diff] [blame] | 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 | } |