| 1 |
// RUN: %clang_cc1 %s -verify -fexceptions |
| 2 |
class A { |
| 3 |
void f() __attribute__((deprecated)); // expected-note 2 {{'f' has been explicitly marked deprecated here}} |
| 4 |
void g(A* a); |
| 5 |
void h(A* a) __attribute__((deprecated)); |
| 6 |
|
| 7 |
int b __attribute__((deprecated)); // expected-note 2 {{'b' has been explicitly marked deprecated here}} |
| 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)); // expected-note 6 {{'f' has been explicitly marked deprecated here}} |
| 30 |
void g(); |
| 31 |
}; |
| 32 |
|
| 33 |
void B::g() { |
| 34 |
f(); // expected-warning{{'f' is deprecated}} |
| 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(); // expected-warning{{'f' is deprecated}} |
| 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));// expected-note{{'f' has been explicitly marked deprecated here}} |
| 60 |
virtual void f(int) __attribute__((deprecated));// expected-note{{'f' has been explicitly marked deprecated here}} |
| 61 |
virtual void f(int, int) __attribute__((deprecated));// expected-note{{'f' has been explicitly marked deprecated here}} |
| 62 |
}; |
| 63 |
|
| 64 |
void D::f() { } |
| 65 |
void D::f(int v) { } |
| 66 |
void D::f(int v1, int v2) { } |
| 67 |
|
| 68 |
void f(D* d) { |
| 69 |
d->f(); // expected-warning{{'f' is deprecated}} |
| 70 |
d->f(42); // expected-warning{{'f' is deprecated}} |
| 71 |
d->f(42, 24); // expected-warning{{'f' is deprecated}} |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
// Overloaded namespace members. |
| 76 |
namespace test1 { |
| 77 |
void foo(int) __attribute__((deprecated)); // expected-note {{'foo' has been explicitly marked deprecated here}} |
| 78 |
void test1() { foo(10); } // expected-warning {{deprecated}} |
| 79 |
void foo(short) __attribute__((deprecated)); // expected-note {{'foo' has been explicitly marked deprecated here}} |
| 80 |
void test2(short s) { foo(s); } // expected-warning {{deprecated}} |
| 81 |
void foo(long); |
| 82 |
void test3(long l) { foo(l); } |
| 83 |
struct A { |
| 84 |
friend void foo(A*) __attribute__((deprecated)); // expected-note {{'foo' has been explicitly marked deprecated here}} |
| 85 |
}; |
| 86 |
void test4(A *a) { foo(a); } // expected-warning {{deprecated}} |
| 87 |
|
| 88 |
namespace ns { |
| 89 |
struct Foo {}; |
| 90 |
void foo(const Foo &f) __attribute__((deprecated)); // expected-note {{'foo' has been explicitly marked deprecated here}} |
| 91 |
} |
| 92 |
void test5() { |
| 93 |
foo(ns::Foo()); // expected-warning {{deprecated}} |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
// Overloaded class members. |
| 98 |
namespace test2 { |
| 99 |
struct A { |
| 100 |
void foo(int) __attribute__((deprecated)); // expected-note 2 {{'foo' has been explicitly marked deprecated here}} |
| 101 |
void foo(long); |
| 102 |
static void bar(int) __attribute__((deprecated)); // expected-note 3 {{'bar' has been explicitly marked deprecated here}} |
| 103 |
static void bar(long); |
| 104 |
|
| 105 |
void test2(int i, long l); |
| 106 |
}; |
| 107 |
void test1(int i, long l) { |
| 108 |
A a; |
| 109 |
a.foo(i); // expected-warning {{deprecated}} |
| 110 |
a.foo(l); |
| 111 |
a.bar(i); // expected-warning {{deprecated}} |
| 112 |
a.bar(l); |
| 113 |
A::bar(i); // expected-warning {{deprecated}} |
| 114 |
A::bar(l); |
| 115 |
} |
| 116 |
|
| 117 |
void A::test2(int i, long l) { |
| 118 |
foo(i); // expected-warning {{deprecated}} |
| 119 |
foo(l); |
| 120 |
bar(i); // expected-warning {{deprecated}} |
| 121 |
bar(l); |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
// Overloaded operators. |
| 126 |
namespace test3 { |
| 127 |
struct A { |
| 128 |
void operator*(const A &); |
| 129 |
void operator*(int) __attribute__((deprecated)); // expected-note {{'operator*' has been explicitly marked deprecated here}} |
| 130 |
void operator-(const A &) const; |
| 131 |
}; |
| 132 |
void operator+(const A &, const A &); |
| 133 |
void operator+(const A &, int) __attribute__((deprecated)); // expected-note {{'operator+' has been explicitly marked deprecated here}} |
| 134 |
void operator-(const A &, int) __attribute__((deprecated)); // expected-note {{'operator-' has been explicitly marked deprecated here}} |
| 135 |
|
| 136 |
void test() { |
| 137 |
A a, b; |
| 138 |
a + b; |
| 139 |
a + 1; // expected-warning {{deprecated}} |
| 140 |
a - b; |
| 141 |
a - 1; // expected-warning {{deprecated}} |
| 142 |
a * b; |
| 143 |
a * 1; // expected-warning {{deprecated}} |
| 144 |
} |
| 145 |
} |
| 146 |
|
| 147 |
// Overloaded operator call. |
| 148 |
namespace test4 { |
| 149 |
struct A { |
| 150 |
typedef void (*intfn)(int); |
| 151 |
typedef void (*unintfn)(unsigned); |
| 152 |
operator intfn() __attribute__((deprecated)); // expected-note {{'operator void (*)(int)' has been explicitly marked deprecated here}} |
| 153 |
operator unintfn(); |
| 154 |
void operator ()(A &) __attribute__((deprecated)); // expected-note {{'operator()' has been explicitly marked deprecated here}} |
| 155 |
void operator ()(const A &); |
| 156 |
}; |
| 157 |
|
| 158 |
void test() { |
| 159 |
A a; |
| 160 |
a(1); // expected-warning {{deprecated}} |
| 161 |
a(1U); |
| 162 |
|
| 163 |
A &b = a; |
| 164 |
const A &c = a; |
| 165 |
a(b); // expected-warning {{deprecated}} |
| 166 |
a(c); |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
namespace test5 { |
| 171 |
struct A { |
| 172 |
operator int() __attribute__((deprecated)); // expected-note 3 {{'operator int' has been explicitly marked deprecated here}} |
| 173 |
operator long(); |
| 174 |
}; |
| 175 |
void test1(A a) { |
| 176 |
int i = a; // expected-warning {{deprecated}} |
| 177 |
long l = a; |
| 178 |
} |
| 179 |
|
| 180 |
void foo(int); |
| 181 |
void foo(void*); |
| 182 |
void bar(long); |
| 183 |
void bar(void*); |
| 184 |
void test2(A a) { |
| 185 |
foo(a); // expected-warning {{deprecated}} |
| 186 |
bar(a); |
| 187 |
} |
| 188 |
|
| 189 |
struct B { |
| 190 |
int myInt; |
| 191 |
long myLong; |
| 192 |
|
| 193 |
B(A &a) : |
| 194 |
myInt(a), // expected-warning {{deprecated}} |
| 195 |
myLong(a) |
| 196 |
{} |
| 197 |
}; |
| 198 |
} |
| 199 |
|
| 200 |
namespace test6 { |
| 201 |
enum __attribute__((deprecated)) A { // expected-note 2 {{'A' has been explicitly marked deprecated here}} |
| 202 |
a0 |
| 203 |
}; |
| 204 |
void testA() { |
| 205 |
A x; // expected-warning {{'A' is deprecated}} |
| 206 |
x = a0; // expected-warning {{'a0' is deprecated}} |
| 207 |
} |
| 208 |
|
| 209 |
enum B { |
| 210 |
b0 __attribute__((deprecated)), // expected-note {{'b0' has been explicitly marked deprecated here}} |
| 211 |
b1 |
| 212 |
}; |
| 213 |
void testB() { |
| 214 |
B x; |
| 215 |
x = b0; // expected-warning {{'b0' is deprecated}} |
| 216 |
x = b1; |
| 217 |
} |
| 218 |
|
| 219 |
template <class T> struct C { |
| 220 |
enum __attribute__((deprecated)) Enum { // expected-note 2 {{'Enum' has been explicitly marked deprecated here}} |
| 221 |
c0 |
| 222 |
}; |
| 223 |
}; |
| 224 |
void testC() { |
| 225 |
C<int>::Enum x; // expected-warning {{'Enum' is deprecated}} |
| 226 |
x = C<int>::c0; // expected-warning {{'c0' is deprecated}} |
| 227 |
} |
| 228 |
|
| 229 |
template <class T> struct D { |
| 230 |
enum Enum { |
| 231 |
d0, |
| 232 |
d1 __attribute__((deprecated)), // expected-note {{'d1' has been explicitly marked deprecated here}} |
| 233 |
}; |
| 234 |
}; |
| 235 |
void testD() { |
| 236 |
D<int>::Enum x; |
| 237 |
x = D<int>::d0; |
| 238 |
x = D<int>::d1; // expected-warning {{'d1' is deprecated}} |
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
namespace test7 { |
| 243 |
struct X { |
| 244 |
void* operator new(typeof(sizeof(void*))) __attribute__((deprecated)); // expected-note{{'operator new' has been explicitly marked deprecated here}} |
| 245 |
void operator delete(void *) __attribute__((deprecated)); // expected-note{{'operator delete' has been explicitly marked deprecated here}} |
| 246 |
}; |
| 247 |
|
| 248 |
void test() { |
| 249 |
X *x = new X; // expected-warning{{'operator new' is deprecated}} expected-warning{{'operator delete' is deprecated}} |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
typedef struct TDS { |
| 254 |
} TDS __attribute__((deprecated)); // expected-note {{'TDS' has been explicitly marked deprecated here}} |
| 255 |
TDS tds; // expected-warning {{'TDS' is deprecated}} |
| 256 |
struct TDS tds2; // no warning, attribute only applies to the typedef. |
| 257 |
|
| 258 |
namespace test8 { |
| 259 |
struct A { |
| 260 |
// expected-note@+1 {{'B' has been explicitly marked deprecated here}} |
| 261 |
struct __attribute__((deprecated)) B {}; |
| 262 |
}; |
| 263 |
template <typename T> struct D : T { |
| 264 |
using typename T::B; |
| 265 |
B b; // expected-warning {{'B' is deprecated}} |
| 266 |
}; |
| 267 |
D<A> da; // expected-note {{in instantiation of template class}} |
| 268 |
} // namespace test8 |