Argyrios Kyrtzidis | 42cbd78 | 2010-08-17 22:06:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function %s |
Argyrios Kyrtzidis | bbc6454 | 2010-08-15 01:15:20 +0000 | [diff] [blame] | 2 | |
| 3 | static void f1(); // expected-warning{{unused}} |
| 4 | |
| 5 | namespace { |
| 6 | void f2(); // expected-warning{{unused}} |
| 7 | |
| 8 | void f3() { } // expected-warning{{unused}} |
| 9 | |
| 10 | struct S { |
| 11 | void m1() { } // expected-warning{{unused}} |
| 12 | void m2(); // expected-warning{{unused}} |
| 13 | void m3(); |
Argyrios Kyrtzidis | 06999f8 | 2010-08-15 10:17:33 +0000 | [diff] [blame] | 14 | S(const S&); |
| 15 | void operator=(const S&); |
Argyrios Kyrtzidis | bbc6454 | 2010-08-15 01:15:20 +0000 | [diff] [blame] | 16 | }; |
| 17 | |
| 18 | template <typename T> |
| 19 | struct TS { |
| 20 | void m(); |
| 21 | }; |
| 22 | template <> void TS<int>::m() { } // expected-warning{{unused}} |
| 23 | |
| 24 | template <typename T> |
| 25 | void tf() { } |
| 26 | template <> void tf<int>() { } // expected-warning{{unused}} |
| 27 | |
| 28 | struct VS { |
| 29 | virtual void vm() { } |
| 30 | }; |
| 31 | |
| 32 | struct SVS : public VS { |
| 33 | void vm() { } |
| 34 | }; |
| 35 | } |
| 36 | |
| 37 | void S::m3() { } // expected-warning{{unused}} |
| 38 | |
| 39 | static inline void f4() { } |
| 40 | const unsigned int cx = 0; |
| 41 | |
| 42 | static int x1; // expected-warning{{unused}} |
| 43 | |
| 44 | namespace { |
| 45 | int x2; // expected-warning{{unused}} |
| 46 | |
| 47 | struct S2 { |
| 48 | static int x; // expected-warning{{unused}} |
| 49 | }; |
| 50 | |
| 51 | template <typename T> |
| 52 | struct TS2 { |
| 53 | static int x; |
| 54 | }; |
| 55 | template <> int TS2<int>::x; // expected-warning{{unused}} |
| 56 | } |
Chandler Carruth | ef9d09c | 2011-01-03 19:27:19 +0000 | [diff] [blame] | 57 | |
| 58 | namespace PR8841 { |
| 59 | // Ensure that friends of class templates are considered to have a dependent |
| 60 | // context and not marked unused. |
| 61 | namespace { |
| 62 | template <typename T> struct X { |
| 63 | friend bool operator==(const X&, const X&) { return false; } |
| 64 | }; |
| 65 | } |
| 66 | template <typename T> void template_test(X<T> x) { |
| 67 | (void)(x == x); |
| 68 | } |
John McCall | af8ca37 | 2011-02-10 06:50:24 +0000 | [diff] [blame] | 69 | void test() { |
| 70 | X<int> x; |
Chandler Carruth | ef9d09c | 2011-01-03 19:27:19 +0000 | [diff] [blame] | 71 | template_test(x); |
| 72 | } |
| 73 | } |
John McCall | af8ca37 | 2011-02-10 06:50:24 +0000 | [diff] [blame] | 74 | |
| 75 | namespace test4 { |
| 76 | namespace { struct A {}; } |
| 77 | |
| 78 | void test(A a); // expected-warning {{unused function}} |
| 79 | extern "C" void test4(A a); |
| 80 | } |
Argyrios Kyrtzidis | 6b6b42a | 2011-04-19 19:51:10 +0000 | [diff] [blame] | 81 | |
| 82 | namespace rdar8733476 { |
| 83 | static void foo() { } // expected-warning {{not needed and will not be emitted}} |
| 84 | |
| 85 | template <int> |
| 86 | void bar() { |
| 87 | foo(); |
| 88 | } |
| 89 | } |