1 // RUN: %clang_cc1 %s -verify -fsyntax-only 2 class A { 3 void f() __attribute__((deprecated)); 4 void g(A* a); 5 void h(A* a) __attribute__((deprecated)); 6 7 int b __attribute__((deprecated)); 8 }; 9 10 void A::g(A* a) 11 { 12 f(); // expected-warning{{'f' is deprecated}} 13 a->f(); // expected-warning{{'f' is deprecated}} 14 15 (void)b; // expected-warning{{'b' is deprecated}} 16 (void)a->b; // expected-warning{{'b' is deprecated}} 17 } 18 19 void A::h(A* a) 20 { 21 f(); 22 a->f(); 23 24 (void)b; 25 (void)a->b; 26 } 27 28 struct B { 29 virtual void f() __attribute__((deprecated)); 30 void g(); 31 }; 32 33 void B::g() { 34 f(); 35 B::f(); // expected-warning{{'f' is deprecated}} 36 } 37 38 struct C : B { 39 virtual void f(); 40 void g(); 41 }; 42 43 void C::g() { 44 f(); 45 C::f(); 46 B::f(); // expected-warning{{'f' is deprecated}} 47 } 48 49 void f(B* b, C *c) { 50 b->f(); 51 b->B::f(); // expected-warning{{'f' is deprecated}} 52 53 c->f(); 54 c->C::f(); 55 c->B::f(); // expected-warning{{'f' is deprecated}} 56 } 57 58 struct D { 59 virtual void f() __attribute__((deprecated)); 60 }; 61 62 void D::f() { } 63 64 void f(D* d) { 65 d->f(); 66 } 67 68 69 // Overloaded namespace members. 70 namespace test1 { 71 void foo(int) __attribute__((deprecated)); 72 void test1() { foo(10); } // expected-warning {{deprecated}} 73 void foo(short) __attribute__((deprecated)); 74 void test2(short s) { foo(s); } // expected-warning {{deprecated}} 75 void foo(long); 76 void test3(long l) { foo(l); } 77 struct A { 78 friend void foo(A*) __attribute__((deprecated)); 79 }; 80 void test4(A *a) { foo(a); } // expected-warning {{deprecated}} 81 82 namespace ns { 83 struct Foo {}; 84 void foo(const Foo &f) __attribute__((deprecated)); 85 } 86 void test5() { 87 foo(ns::Foo()); // expected-warning {{deprecated}} 88 } 89 } 90 91 // Overloaded class members. 92 namespace test2 { 93 struct A { 94 void foo(int) __attribute__((deprecated)); 95 void foo(long); 96 static void bar(int) __attribute__((deprecated)); 97 static void bar(long); 98 99 void test2(int i, long l); 100 }; 101 void test1(int i, long l) { 102 A a; 103 a.foo(i); // expected-warning {{deprecated}} 104 a.foo(l); 105 a.bar(i); // expected-warning {{deprecated}} 106 a.bar(l); 107 A::bar(i); // expected-warning {{deprecated}} 108 A::bar(l); 109 } 110 111 void A::test2(int i, long l) { 112 foo(i); // expected-warning {{deprecated}} 113 foo(l); 114 bar(i); // expected-warning {{deprecated}} 115 bar(l); 116 } 117 } 118 119 // Overloaded operators. 120 namespace test3 { 121 struct A { 122 void operator*(const A &); 123 void operator*(int) __attribute__((deprecated)); 124 void operator-(const A &) const; 125 }; 126 void operator+(const A &, const A &); 127 void operator+(const A &, int) __attribute__((deprecated)); 128 void operator-(const A &, int) __attribute__((deprecated)); 129 130 void test() { 131 A a, b; 132 a + b; 133 a + 1; // expected-warning {{deprecated}} 134 a - b; 135 a - 1; // expected-warning {{deprecated}} 136 a * b; 137 a * 1; // expected-warning {{deprecated}} 138 } 139 } 140 141 // Overloaded operator call. 142 namespace test4 { 143 struct A { 144 typedef void (*intfn)(int); 145 typedef void (*unintfn)(unsigned); 146 operator intfn() __attribute__((deprecated)); 147 operator unintfn(); 148 void operator ()(A &) __attribute__((deprecated)); 149 void operator ()(const A &); 150 }; 151 152 void test() { 153 A a; 154 a(1); // expected-warning {{deprecated}} 155 a(1U); 156 157 A &b = a; 158 const A &c = a; 159 a(b); // expected-warning {{deprecated}} 160 a(c); 161 } 162 } 163 164 namespace test5 { 165 struct A { 166 operator int() __attribute__((deprecated)); 167 operator long(); 168 }; 169 void test1(A a) { 170 int i = a; // expected-warning {{deprecated}} 171 long l = a; 172 } 173 174 void foo(int); 175 void foo(void*); 176 void bar(long); 177 void bar(void*); 178 void test2(A a) { 179 foo(a); // expected-warning {{deprecated}} 180 bar(a); 181 } 182 183 struct B { 184 int myInt; 185 long myLong; 186 187 B(A &a) : 188 myInt(a), // expected-warning {{deprecated}} 189 myLong(a) 190 {} 191 }; 192 } 193