Anders Carlsson | cd1af3d | 2010-10-24 04:28:00 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s |
Daniel Dunbar | d3f2c10 | 2008-10-19 02:04:16 +0000 | [diff] [blame] | 2 | |
| 3 | static void (*fp0)(void) __attribute__((unused)); |
| 4 | |
| 5 | static void __attribute__((unused)) f0(void); |
| 6 | |
| 7 | // On K&R |
| 8 | int f1() __attribute__((unused)); |
| 9 | |
| 10 | int g0 __attribute__((unused)); |
| 11 | |
Aaron Ballman | baec778 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 12 | int f2() __attribute__((unused(1, 2))); // expected-error {{'unused' attribute takes no arguments}} |
John McCall | aec5860 | 2010-03-31 02:47:45 +0000 | [diff] [blame] | 13 | |
| 14 | struct Test0_unused {} __attribute__((unused)); |
| 15 | struct Test0_not_unused {}; |
| 16 | typedef int Int_unused __attribute__((unused)); |
| 17 | typedef int Int_not_unused; |
| 18 | |
| 19 | void test0() { |
| 20 | int x; // expected-warning {{unused variable}} |
| 21 | |
| 22 | Int_not_unused i0; // expected-warning {{unused variable}} |
Anders Carlsson | 2127ecc | 2010-10-22 23:37:08 +0000 | [diff] [blame] | 23 | Int_unused i1; // expected-warning {{'Int_unused' was marked unused but was used}} |
John McCall | aec5860 | 2010-03-31 02:47:45 +0000 | [diff] [blame] | 24 | |
| 25 | struct Test0_not_unused s0; // expected-warning {{unused variable}} |
Anders Carlsson | 2127ecc | 2010-10-22 23:37:08 +0000 | [diff] [blame] | 26 | struct Test0_unused s1; // expected-warning {{'Test0_unused' was marked unused but was used}} |
| 27 | } |
| 28 | |
| 29 | int f3(int x) { // expected-warning{{unused parameter 'x'}} |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | int f4(int x) { |
| 34 | return x; |
| 35 | } |
| 36 | |
| 37 | int f5(int x __attribute__((__unused__))) { |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | int f6(int x __attribute__((__unused__))) { |
| 42 | return x; // expected-warning{{'x' was marked unused but was used}} |
John McCall | aec5860 | 2010-03-31 02:47:45 +0000 | [diff] [blame] | 43 | } |