1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -verify -fexceptions
2f4a2713aSLionel Sambuc class A {
3*0a6a1f1dSLionel Sambuc void f() __attribute__((deprecated)); // expected-note 2 {{'f' has been explicitly marked deprecated here}}
4f4a2713aSLionel Sambuc void g(A* a);
5f4a2713aSLionel Sambuc void h(A* a) __attribute__((deprecated));
6f4a2713aSLionel Sambuc
7*0a6a1f1dSLionel Sambuc int b __attribute__((deprecated)); // expected-note 2 {{'b' has been explicitly marked deprecated here}}
8f4a2713aSLionel Sambuc };
9f4a2713aSLionel Sambuc
g(A * a)10f4a2713aSLionel Sambuc void A::g(A* a)
11f4a2713aSLionel Sambuc {
12f4a2713aSLionel Sambuc f(); // expected-warning{{'f' is deprecated}}
13f4a2713aSLionel Sambuc a->f(); // expected-warning{{'f' is deprecated}}
14f4a2713aSLionel Sambuc
15f4a2713aSLionel Sambuc (void)b; // expected-warning{{'b' is deprecated}}
16f4a2713aSLionel Sambuc (void)a->b; // expected-warning{{'b' is deprecated}}
17f4a2713aSLionel Sambuc }
18f4a2713aSLionel Sambuc
h(A * a)19f4a2713aSLionel Sambuc void A::h(A* a)
20f4a2713aSLionel Sambuc {
21f4a2713aSLionel Sambuc f();
22f4a2713aSLionel Sambuc a->f();
23f4a2713aSLionel Sambuc
24f4a2713aSLionel Sambuc (void)b;
25f4a2713aSLionel Sambuc (void)a->b;
26f4a2713aSLionel Sambuc }
27f4a2713aSLionel Sambuc
28f4a2713aSLionel Sambuc struct B {
29*0a6a1f1dSLionel Sambuc virtual void f() __attribute__((deprecated)); // expected-note 4 {{'f' has been explicitly marked deprecated here}}
30f4a2713aSLionel Sambuc void g();
31f4a2713aSLionel Sambuc };
32f4a2713aSLionel Sambuc
g()33f4a2713aSLionel Sambuc void B::g() {
34f4a2713aSLionel Sambuc f();
35f4a2713aSLionel Sambuc B::f(); // expected-warning{{'f' is deprecated}}
36f4a2713aSLionel Sambuc }
37f4a2713aSLionel Sambuc
38f4a2713aSLionel Sambuc struct C : B {
39f4a2713aSLionel Sambuc virtual void f();
40f4a2713aSLionel Sambuc void g();
41f4a2713aSLionel Sambuc };
42f4a2713aSLionel Sambuc
g()43f4a2713aSLionel Sambuc void C::g() {
44f4a2713aSLionel Sambuc f();
45f4a2713aSLionel Sambuc C::f();
46f4a2713aSLionel Sambuc B::f(); // expected-warning{{'f' is deprecated}}
47f4a2713aSLionel Sambuc }
48f4a2713aSLionel Sambuc
f(B * b,C * c)49f4a2713aSLionel Sambuc void f(B* b, C *c) {
50f4a2713aSLionel Sambuc b->f();
51f4a2713aSLionel Sambuc b->B::f(); // expected-warning{{'f' is deprecated}}
52f4a2713aSLionel Sambuc
53f4a2713aSLionel Sambuc c->f();
54f4a2713aSLionel Sambuc c->C::f();
55f4a2713aSLionel Sambuc c->B::f(); // expected-warning{{'f' is deprecated}}
56f4a2713aSLionel Sambuc }
57f4a2713aSLionel Sambuc
58f4a2713aSLionel Sambuc struct D {
59f4a2713aSLionel Sambuc virtual void f() __attribute__((deprecated));
60f4a2713aSLionel Sambuc };
61f4a2713aSLionel Sambuc
f()62f4a2713aSLionel Sambuc void D::f() { }
63f4a2713aSLionel Sambuc
f(D * d)64f4a2713aSLionel Sambuc void f(D* d) {
65f4a2713aSLionel Sambuc d->f();
66f4a2713aSLionel Sambuc }
67f4a2713aSLionel Sambuc
68f4a2713aSLionel Sambuc
69f4a2713aSLionel Sambuc // Overloaded namespace members.
70f4a2713aSLionel Sambuc namespace test1 {
71*0a6a1f1dSLionel Sambuc void foo(int) __attribute__((deprecated)); // expected-note {{'foo' has been explicitly marked deprecated here}}
test1()72f4a2713aSLionel Sambuc void test1() { foo(10); } // expected-warning {{deprecated}}
73*0a6a1f1dSLionel Sambuc void foo(short) __attribute__((deprecated)); // expected-note {{'foo' has been explicitly marked deprecated here}}
test2(short s)74f4a2713aSLionel Sambuc void test2(short s) { foo(s); } // expected-warning {{deprecated}}
75f4a2713aSLionel Sambuc void foo(long);
test3(long l)76f4a2713aSLionel Sambuc void test3(long l) { foo(l); }
77f4a2713aSLionel Sambuc struct A {
78*0a6a1f1dSLionel Sambuc friend void foo(A*) __attribute__((deprecated)); // expected-note {{'foo' has been explicitly marked deprecated here}}
79f4a2713aSLionel Sambuc };
test4(A * a)80f4a2713aSLionel Sambuc void test4(A *a) { foo(a); } // expected-warning {{deprecated}}
81f4a2713aSLionel Sambuc
82f4a2713aSLionel Sambuc namespace ns {
83f4a2713aSLionel Sambuc struct Foo {};
84*0a6a1f1dSLionel Sambuc void foo(const Foo &f) __attribute__((deprecated)); // expected-note {{'foo' has been explicitly marked deprecated here}}
85f4a2713aSLionel Sambuc }
test5()86f4a2713aSLionel Sambuc void test5() {
87f4a2713aSLionel Sambuc foo(ns::Foo()); // expected-warning {{deprecated}}
88f4a2713aSLionel Sambuc }
89f4a2713aSLionel Sambuc }
90f4a2713aSLionel Sambuc
91f4a2713aSLionel Sambuc // Overloaded class members.
92f4a2713aSLionel Sambuc namespace test2 {
93f4a2713aSLionel Sambuc struct A {
94*0a6a1f1dSLionel Sambuc void foo(int) __attribute__((deprecated)); // expected-note 2 {{'foo' has been explicitly marked deprecated here}}
95f4a2713aSLionel Sambuc void foo(long);
96*0a6a1f1dSLionel Sambuc static void bar(int) __attribute__((deprecated)); // expected-note 3 {{'bar' has been explicitly marked deprecated here}}
97f4a2713aSLionel Sambuc static void bar(long);
98f4a2713aSLionel Sambuc
99f4a2713aSLionel Sambuc void test2(int i, long l);
100f4a2713aSLionel Sambuc };
test1(int i,long l)101f4a2713aSLionel Sambuc void test1(int i, long l) {
102f4a2713aSLionel Sambuc A a;
103f4a2713aSLionel Sambuc a.foo(i); // expected-warning {{deprecated}}
104f4a2713aSLionel Sambuc a.foo(l);
105f4a2713aSLionel Sambuc a.bar(i); // expected-warning {{deprecated}}
106f4a2713aSLionel Sambuc a.bar(l);
107f4a2713aSLionel Sambuc A::bar(i); // expected-warning {{deprecated}}
108f4a2713aSLionel Sambuc A::bar(l);
109f4a2713aSLionel Sambuc }
110f4a2713aSLionel Sambuc
test2(int i,long l)111f4a2713aSLionel Sambuc void A::test2(int i, long l) {
112f4a2713aSLionel Sambuc foo(i); // expected-warning {{deprecated}}
113f4a2713aSLionel Sambuc foo(l);
114f4a2713aSLionel Sambuc bar(i); // expected-warning {{deprecated}}
115f4a2713aSLionel Sambuc bar(l);
116f4a2713aSLionel Sambuc }
117f4a2713aSLionel Sambuc }
118f4a2713aSLionel Sambuc
119f4a2713aSLionel Sambuc // Overloaded operators.
120f4a2713aSLionel Sambuc namespace test3 {
121f4a2713aSLionel Sambuc struct A {
122f4a2713aSLionel Sambuc void operator*(const A &);
123*0a6a1f1dSLionel Sambuc void operator*(int) __attribute__((deprecated)); // expected-note {{'operator*' has been explicitly marked deprecated here}}
124f4a2713aSLionel Sambuc void operator-(const A &) const;
125f4a2713aSLionel Sambuc };
126f4a2713aSLionel Sambuc void operator+(const A &, const A &);
127*0a6a1f1dSLionel Sambuc void operator+(const A &, int) __attribute__((deprecated)); // expected-note {{'operator+' has been explicitly marked deprecated here}}
128*0a6a1f1dSLionel Sambuc void operator-(const A &, int) __attribute__((deprecated)); // expected-note {{'operator-' has been explicitly marked deprecated here}}
129f4a2713aSLionel Sambuc
test()130f4a2713aSLionel Sambuc void test() {
131f4a2713aSLionel Sambuc A a, b;
132f4a2713aSLionel Sambuc a + b;
133f4a2713aSLionel Sambuc a + 1; // expected-warning {{deprecated}}
134f4a2713aSLionel Sambuc a - b;
135f4a2713aSLionel Sambuc a - 1; // expected-warning {{deprecated}}
136f4a2713aSLionel Sambuc a * b;
137f4a2713aSLionel Sambuc a * 1; // expected-warning {{deprecated}}
138f4a2713aSLionel Sambuc }
139f4a2713aSLionel Sambuc }
140f4a2713aSLionel Sambuc
141f4a2713aSLionel Sambuc // Overloaded operator call.
142f4a2713aSLionel Sambuc namespace test4 {
143f4a2713aSLionel Sambuc struct A {
144f4a2713aSLionel Sambuc typedef void (*intfn)(int);
145f4a2713aSLionel Sambuc typedef void (*unintfn)(unsigned);
146*0a6a1f1dSLionel Sambuc operator intfn() __attribute__((deprecated)); // expected-note {{'operator void (*)(int)' has been explicitly marked deprecated here}}
147f4a2713aSLionel Sambuc operator unintfn();
148*0a6a1f1dSLionel Sambuc void operator ()(A &) __attribute__((deprecated)); // expected-note {{'operator()' has been explicitly marked deprecated here}}
149f4a2713aSLionel Sambuc void operator ()(const A &);
150f4a2713aSLionel Sambuc };
151f4a2713aSLionel Sambuc
test()152f4a2713aSLionel Sambuc void test() {
153f4a2713aSLionel Sambuc A a;
154f4a2713aSLionel Sambuc a(1); // expected-warning {{deprecated}}
155f4a2713aSLionel Sambuc a(1U);
156f4a2713aSLionel Sambuc
157f4a2713aSLionel Sambuc A &b = a;
158f4a2713aSLionel Sambuc const A &c = a;
159f4a2713aSLionel Sambuc a(b); // expected-warning {{deprecated}}
160f4a2713aSLionel Sambuc a(c);
161f4a2713aSLionel Sambuc }
162f4a2713aSLionel Sambuc }
163f4a2713aSLionel Sambuc
164f4a2713aSLionel Sambuc namespace test5 {
165f4a2713aSLionel Sambuc struct A {
166*0a6a1f1dSLionel Sambuc operator int() __attribute__((deprecated)); // expected-note 3 {{'operator int' has been explicitly marked deprecated here}}
167f4a2713aSLionel Sambuc operator long();
168f4a2713aSLionel Sambuc };
test1(A a)169f4a2713aSLionel Sambuc void test1(A a) {
170f4a2713aSLionel Sambuc int i = a; // expected-warning {{deprecated}}
171f4a2713aSLionel Sambuc long l = a;
172f4a2713aSLionel Sambuc }
173f4a2713aSLionel Sambuc
174f4a2713aSLionel Sambuc void foo(int);
175f4a2713aSLionel Sambuc void foo(void*);
176f4a2713aSLionel Sambuc void bar(long);
177f4a2713aSLionel Sambuc void bar(void*);
test2(A a)178f4a2713aSLionel Sambuc void test2(A a) {
179f4a2713aSLionel Sambuc foo(a); // expected-warning {{deprecated}}
180f4a2713aSLionel Sambuc bar(a);
181f4a2713aSLionel Sambuc }
182f4a2713aSLionel Sambuc
183f4a2713aSLionel Sambuc struct B {
184f4a2713aSLionel Sambuc int myInt;
185f4a2713aSLionel Sambuc long myLong;
186f4a2713aSLionel Sambuc
Btest5::B187f4a2713aSLionel Sambuc B(A &a) :
188f4a2713aSLionel Sambuc myInt(a), // expected-warning {{deprecated}}
189f4a2713aSLionel Sambuc myLong(a)
190f4a2713aSLionel Sambuc {}
191f4a2713aSLionel Sambuc };
192f4a2713aSLionel Sambuc }
193f4a2713aSLionel Sambuc
194f4a2713aSLionel Sambuc // rdar://problem/8518751
195f4a2713aSLionel Sambuc namespace test6 {
196*0a6a1f1dSLionel Sambuc enum __attribute__((deprecated)) A { // expected-note {{'A' has been explicitly marked deprecated here}}
197*0a6a1f1dSLionel Sambuc a0 // expected-note {{'a0' has been explicitly marked deprecated here}}
198f4a2713aSLionel Sambuc };
testA()199f4a2713aSLionel Sambuc void testA() {
200f4a2713aSLionel Sambuc A x; // expected-warning {{'A' is deprecated}}
201f4a2713aSLionel Sambuc x = a0; // expected-warning {{'a0' is deprecated}}
202f4a2713aSLionel Sambuc }
203f4a2713aSLionel Sambuc
204f4a2713aSLionel Sambuc enum B {
205*0a6a1f1dSLionel Sambuc b0 __attribute__((deprecated)), // expected-note {{'b0' has been explicitly marked deprecated here}}
206f4a2713aSLionel Sambuc b1
207f4a2713aSLionel Sambuc };
testB()208f4a2713aSLionel Sambuc void testB() {
209f4a2713aSLionel Sambuc B x;
210f4a2713aSLionel Sambuc x = b0; // expected-warning {{'b0' is deprecated}}
211f4a2713aSLionel Sambuc x = b1;
212f4a2713aSLionel Sambuc }
213f4a2713aSLionel Sambuc
214f4a2713aSLionel Sambuc template <class T> struct C {
215*0a6a1f1dSLionel Sambuc enum __attribute__((deprecated)) Enum { // expected-note {{'Enum' has been explicitly marked deprecated here}}
216*0a6a1f1dSLionel Sambuc c0 // expected-note {{'c0' has been explicitly marked deprecated here}}
217f4a2713aSLionel Sambuc };
218f4a2713aSLionel Sambuc };
testC()219f4a2713aSLionel Sambuc void testC() {
220f4a2713aSLionel Sambuc C<int>::Enum x; // expected-warning {{'Enum' is deprecated}}
221f4a2713aSLionel Sambuc x = C<int>::c0; // expected-warning {{'c0' is deprecated}}
222f4a2713aSLionel Sambuc }
223f4a2713aSLionel Sambuc
224f4a2713aSLionel Sambuc template <class T> struct D {
225f4a2713aSLionel Sambuc enum Enum {
226f4a2713aSLionel Sambuc d0,
227*0a6a1f1dSLionel Sambuc d1 __attribute__((deprecated)), // expected-note {{'d1' has been explicitly marked deprecated here}}
228f4a2713aSLionel Sambuc };
229f4a2713aSLionel Sambuc };
testD()230f4a2713aSLionel Sambuc void testD() {
231f4a2713aSLionel Sambuc D<int>::Enum x;
232f4a2713aSLionel Sambuc x = D<int>::d0;
233f4a2713aSLionel Sambuc x = D<int>::d1; // expected-warning {{'d1' is deprecated}}
234f4a2713aSLionel Sambuc }
235f4a2713aSLionel Sambuc }
236f4a2713aSLionel Sambuc
237f4a2713aSLionel Sambuc namespace test7 {
238f4a2713aSLionel Sambuc struct X {
239*0a6a1f1dSLionel Sambuc void* operator new(typeof(sizeof(void*))) __attribute__((deprecated)); // expected-note{{'operator new' has been explicitly marked deprecated here}}
240*0a6a1f1dSLionel Sambuc void operator delete(void *) __attribute__((deprecated)); // expected-note{{'operator delete' has been explicitly marked deprecated here}}
241f4a2713aSLionel Sambuc };
242f4a2713aSLionel Sambuc
test()243f4a2713aSLionel Sambuc void test() {
244f4a2713aSLionel Sambuc X *x = new X; // expected-warning{{'operator new' is deprecated}} expected-warning{{'operator delete' is deprecated}}
245f4a2713aSLionel Sambuc }
246f4a2713aSLionel Sambuc }
247f4a2713aSLionel Sambuc
248f4a2713aSLionel Sambuc // rdar://problem/15044218
249f4a2713aSLionel Sambuc typedef struct TDS {
250*0a6a1f1dSLionel Sambuc } TDS __attribute__((deprecated)); // expected-note {{'TDS' has been explicitly marked deprecated here}}
251f4a2713aSLionel Sambuc TDS tds; // expected-warning {{'TDS' is deprecated}}
252f4a2713aSLionel Sambuc struct TDS tds2; // no warning, attribute only applies to the typedef.
253