2012-09-07 00:43:18 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -Wused-but-marked-unused -Wunused-function -Wunneeded-internal-declaration -verify %s
|
2010-04-09 01:54:28 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s
|
2015-06-19 05:09:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wall -Wno-infinite-recursion %s
|
2010-02-12 08:07:30 +08:00
|
|
|
|
|
|
|
void foo() {}
|
|
|
|
static void f2() {}
|
|
|
|
static void f1() {f2();} // expected-warning{{unused}}
|
|
|
|
|
2011-04-20 03:51:10 +08:00
|
|
|
static int f0() { return 17; } // expected-warning{{not needed and will not be emitted}}
|
2010-02-12 08:07:30 +08:00
|
|
|
int x = sizeof(f0());
|
|
|
|
|
|
|
|
static void f3();
|
|
|
|
extern void f3() { } // expected-warning{{unused}}
|
|
|
|
|
2013-10-17 12:13:35 +08:00
|
|
|
inline static void f4();
|
|
|
|
void f4() { } // expected-warning{{unused}}
|
2010-02-17 10:17:21 +08:00
|
|
|
|
|
|
|
static void __attribute__((used)) f5() {}
|
|
|
|
static void f6();
|
|
|
|
static void __attribute__((used)) f6();
|
|
|
|
static void f6() {};
|
|
|
|
|
|
|
|
static void f7(void);
|
|
|
|
void f8(void(*a0)(void));
|
|
|
|
void f9(void) { f8(f7); }
|
|
|
|
static void f7(void) {}
|
2010-02-17 12:48:01 +08:00
|
|
|
|
|
|
|
__attribute__((unused)) static void bar(void);
|
|
|
|
void bar(void) { }
|
|
|
|
|
2010-04-10 01:25:05 +08:00
|
|
|
__attribute__((constructor)) static void bar2(void);
|
|
|
|
void bar2(void) { }
|
|
|
|
|
|
|
|
__attribute__((destructor)) static void bar3(void);
|
|
|
|
void bar3(void) { }
|
2010-08-15 09:15:20 +08:00
|
|
|
|
|
|
|
static void f10(void); // expected-warning{{unused}}
|
|
|
|
static void f10(void);
|
|
|
|
|
|
|
|
static void f11(void);
|
|
|
|
static void f11(void) { } // expected-warning{{unused}}
|
|
|
|
|
|
|
|
static void f12(void) { } // expected-warning{{unused}}
|
|
|
|
static void f12(void);
|
2010-08-25 18:34:54 +08:00
|
|
|
|
|
|
|
// PR7923
|
2011-04-20 03:51:10 +08:00
|
|
|
static void unused(void) { unused(); } // expected-warning{{not needed and will not be emitted}}
|
2010-12-04 09:12:11 +08:00
|
|
|
|
|
|
|
// rdar://8728293
|
|
|
|
static void cleanupMalloc(char * const * const allocation) { }
|
|
|
|
void f13(void) {
|
|
|
|
char * const __attribute__((cleanup(cleanupMalloc))) a;
|
|
|
|
(void)a;
|
|
|
|
}
|
2012-09-07 00:43:18 +08:00
|
|
|
|
|
|
|
// rdar://12233989
|
|
|
|
extern void a(void) __attribute__((unused));
|
|
|
|
extern void b(void) __attribute__((unused));
|
|
|
|
|
|
|
|
void b(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void a(void)
|
|
|
|
{
|
|
|
|
b();
|
|
|
|
}
|