blob: 07c65cbd9aede00511c0eaf2fdefdf7758e207a6 [file] [log] [blame]
Anders Carlssoncd1af3d2010-10-24 04:28:00 +00001// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
Daniel Dunbard3f2c102008-10-19 02:04:16 +00002
3static void (*fp0)(void) __attribute__((unused));
4
5static void __attribute__((unused)) f0(void);
6
7// On K&R
8int f1() __attribute__((unused));
9
10int g0 __attribute__((unused));
11
John McCallbdc49d32011-03-02 12:15:05 +000012int f2() __attribute__((unused(1, 2))); // expected-error {{attribute takes no arguments}}
John McCallaec58602010-03-31 02:47:45 +000013
14struct Test0_unused {} __attribute__((unused));
15struct Test0_not_unused {};
16typedef int Int_unused __attribute__((unused));
17typedef int Int_not_unused;
18
19void test0() {
20 int x; // expected-warning {{unused variable}}
21
22 Int_not_unused i0; // expected-warning {{unused variable}}
Anders Carlsson2127ecc2010-10-22 23:37:08 +000023 Int_unused i1; // expected-warning {{'Int_unused' was marked unused but was used}}
John McCallaec58602010-03-31 02:47:45 +000024
25 struct Test0_not_unused s0; // expected-warning {{unused variable}}
Anders Carlsson2127ecc2010-10-22 23:37:08 +000026 struct Test0_unused s1; // expected-warning {{'Test0_unused' was marked unused but was used}}
27}
28
29int f3(int x) { // expected-warning{{unused parameter 'x'}}
30 return 0;
31}
32
33int f4(int x) {
34 return x;
35}
36
37int f5(int x __attribute__((__unused__))) {
38 return 0;
39}
40
41int f6(int x __attribute__((__unused__))) {
42 return x; // expected-warning{{'x' was marked unused but was used}}
John McCallaec58602010-03-31 02:47:45 +000043}