blob: 013b925f89d85c51d28dcb0fd2a013f1fe621cc1 [file] [log] [blame]
Fariborz Jahanian2d40d9e2012-09-06 16:43:18 +00001// RUN: %clang_cc1 -fsyntax-only -Wused-but-marked-unused -Wunused-function -Wunneeded-internal-declaration -verify %s
Ted Kremeneke1fcf292010-04-08 17:54:28 +00002// RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s
3// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
Tanya Lattnere6bbc012010-02-12 00:07:30 +00004
5void foo() {}
6static void f2() {}
7static void f1() {f2();} // expected-warning{{unused}}
8
Argyrios Kyrtzidis6b6b42a2011-04-19 19:51:10 +00009static int f0() { return 17; } // expected-warning{{not needed and will not be emitted}}
Tanya Lattnere6bbc012010-02-12 00:07:30 +000010int x = sizeof(f0());
11
12static void f3();
13extern void f3() { } // expected-warning{{unused}}
14
Bill Wendling251b18d2013-10-17 04:13:35 +000015inline static void f4();
16void f4() { } // expected-warning{{unused}}
Tanya Lattner12ead492010-02-17 02:17:21 +000017
18static void __attribute__((used)) f5() {}
19static void f6();
20static void __attribute__((used)) f6();
21static void f6() {};
22
23static void f7(void);
24void f8(void(*a0)(void));
25void f9(void) { f8(f7); }
26static void f7(void) {}
Tanya Lattnerc7772212010-02-17 04:48:01 +000027
28__attribute__((unused)) static void bar(void);
29void bar(void) { }
30
Chris Lattner1a4221c2010-04-09 17:25:05 +000031__attribute__((constructor)) static void bar2(void);
32void bar2(void) { }
33
34__attribute__((destructor)) static void bar3(void);
35void bar3(void) { }
Argyrios Kyrtzidisbbc64542010-08-15 01:15:20 +000036
37static void f10(void); // expected-warning{{unused}}
38static void f10(void);
39
40static void f11(void);
41static void f11(void) { } // expected-warning{{unused}}
42
43static void f12(void) { } // expected-warning{{unused}}
44static void f12(void);
Argyrios Kyrtzidis58b52592010-08-25 10:34:54 +000045
46// PR7923
Argyrios Kyrtzidis6b6b42a2011-04-19 19:51:10 +000047static void unused(void) { unused(); } // expected-warning{{not needed and will not be emitted}}
Argyrios Kyrtzidisae3038c2010-12-04 01:12:11 +000048
49// rdar://8728293
50static void cleanupMalloc(char * const * const allocation) { }
51void f13(void) {
52 char * const __attribute__((cleanup(cleanupMalloc))) a;
53 (void)a;
54}
Fariborz Jahanian2d40d9e2012-09-06 16:43:18 +000055
56// rdar://12233989
57extern void a(void) __attribute__((unused));
58extern void b(void) __attribute__((unused));
59
60void b(void)
61{
62}
63void a(void)
64{
65 b();
66}