Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -verify -fsyntax-only |
Anders Carlsson | 0f44b5a | 2009-08-08 16:55:18 +0000 | [diff] [blame] | 2 | class A { |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 3 | void f() __attribute__((deprecated)); // expected-note 2 {{declared here}} |
Anders Carlsson | 0f44b5a | 2009-08-08 16:55:18 +0000 | [diff] [blame] | 4 | void g(A* a); |
Anders Carlsson | fb7ef75 | 2009-08-08 17:48:49 +0000 | [diff] [blame] | 5 | void h(A* a) __attribute__((deprecated)); |
Anders Carlsson | 0f44b5a | 2009-08-08 16:55:18 +0000 | [diff] [blame] | 6 | |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 7 | int b __attribute__((deprecated)); // expected-note 2 {{declared here}} |
Anders Carlsson | 0f44b5a | 2009-08-08 16:55:18 +0000 | [diff] [blame] | 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 | } |
Anders Carlsson | fb7ef75 | 2009-08-08 17:48:49 +0000 | [diff] [blame] | 18 | |
| 19 | void A::h(A* a) |
| 20 | { |
| 21 | f(); |
| 22 | a->f(); |
| 23 | |
| 24 | (void)b; |
| 25 | (void)a->b; |
| 26 | } |
Anders Carlsson | 0f72856 | 2009-09-10 20:48:14 +0000 | [diff] [blame] | 27 | |
| 28 | struct B { |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 29 | virtual void f() __attribute__((deprecated)); // expected-note 4 {{declared here}} |
Anders Carlsson | ed90c4e | 2009-09-11 05:54:14 +0000 | [diff] [blame] | 30 | void g(); |
Anders Carlsson | 0f72856 | 2009-09-10 20:48:14 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
Anders Carlsson | ed90c4e | 2009-09-11 05:54:14 +0000 | [diff] [blame] | 33 | void B::g() { |
| 34 | f(); |
| 35 | B::f(); // expected-warning{{'f' is deprecated}} |
| 36 | } |
| 37 | |
Anders Carlsson | 0f72856 | 2009-09-10 20:48:14 +0000 | [diff] [blame] | 38 | struct C : B { |
| 39 | virtual void f(); |
Anders Carlsson | ed90c4e | 2009-09-11 05:54:14 +0000 | [diff] [blame] | 40 | void g(); |
Anders Carlsson | 0f72856 | 2009-09-10 20:48:14 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
Anders Carlsson | ed90c4e | 2009-09-11 05:54:14 +0000 | [diff] [blame] | 43 | void C::g() { |
| 44 | f(); |
| 45 | C::f(); |
| 46 | B::f(); // expected-warning{{'f' is deprecated}} |
| 47 | } |
| 48 | |
Anders Carlsson | 0f72856 | 2009-09-10 20:48:14 +0000 | [diff] [blame] | 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 | } |
Anders Carlsson | 8195bc9 | 2009-09-13 21:01:57 +0000 | [diff] [blame] | 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 | } |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 67 | |
| 68 | |
| 69 | // Overloaded namespace members. |
| 70 | namespace test1 { |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 71 | void foo(int) __attribute__((deprecated)); // expected-note {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 72 | void test1() { foo(10); } // expected-warning {{deprecated}} |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 73 | void foo(short) __attribute__((deprecated)); // expected-note {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 74 | void test2(short s) { foo(s); } // expected-warning {{deprecated}} |
| 75 | void foo(long); |
| 76 | void test3(long l) { foo(l); } |
| 77 | struct A { |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 78 | friend void foo(A*) __attribute__((deprecated)); // expected-note {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 79 | }; |
| 80 | void test4(A *a) { foo(a); } // expected-warning {{deprecated}} |
| 81 | |
| 82 | namespace ns { |
| 83 | struct Foo {}; |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 84 | void foo(const Foo &f) __attribute__((deprecated)); // expected-note {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 85 | } |
| 86 | void test5() { |
| 87 | foo(ns::Foo()); // expected-warning {{deprecated}} |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | // Overloaded class members. |
| 92 | namespace test2 { |
| 93 | struct A { |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 94 | void foo(int) __attribute__((deprecated)); // expected-note 2 {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 95 | void foo(long); |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 96 | static void bar(int) __attribute__((deprecated)); // expected-note 3 {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 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 &); |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 123 | void operator*(int) __attribute__((deprecated)); // expected-note {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 124 | void operator-(const A &) const; |
| 125 | }; |
| 126 | void operator+(const A &, const A &); |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 127 | void operator+(const A &, int) __attribute__((deprecated)); // expected-note {{declared here}} |
| 128 | void operator-(const A &, int) __attribute__((deprecated)); // expected-note {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 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); |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 146 | operator intfn() __attribute__((deprecated)); // expected-note {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 147 | operator unintfn(); |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 148 | void operator ()(A &) __attribute__((deprecated)); // expected-note {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 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 { |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 166 | operator int() __attribute__((deprecated)); // expected-note 2 {{declared here}} |
John McCall | b697e08 | 2010-05-06 18:15:07 +0000 | [diff] [blame] | 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 | } |
John McCall | 5b629aa | 2010-10-22 23:36:17 +0000 | [diff] [blame] | 193 | |
| 194 | // rdar://problem/8518751 |
| 195 | namespace test6 { |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 196 | enum __attribute__((deprecated)) A { // expected-note {{declared here}} |
| 197 | a0 // expected-note {{declared here}} |
John McCall | 5b629aa | 2010-10-22 23:36:17 +0000 | [diff] [blame] | 198 | }; |
| 199 | void testA() { |
| 200 | A x; // expected-warning {{'A' is deprecated}} |
Fariborz Jahanian | 39b4fc8 | 2011-11-28 19:45:58 +0000 | [diff] [blame] | 201 | x = a0; // expected-warning {{'a0' is deprecated}} |
John McCall | 5b629aa | 2010-10-22 23:36:17 +0000 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | enum B { |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 205 | b0 __attribute__((deprecated)), // expected-note {{declared here}} |
John McCall | 5b629aa | 2010-10-22 23:36:17 +0000 | [diff] [blame] | 206 | b1 |
| 207 | }; |
| 208 | void testB() { |
| 209 | B x; |
| 210 | x = b0; // expected-warning {{'b0' is deprecated}} |
| 211 | x = b1; |
| 212 | } |
| 213 | |
| 214 | template <class T> struct C { |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 215 | enum __attribute__((deprecated)) Enum { // expected-note {{declared here}} |
| 216 | c0 // expected-note {{declared here}} |
John McCall | 5b629aa | 2010-10-22 23:36:17 +0000 | [diff] [blame] | 217 | }; |
| 218 | }; |
| 219 | void testC() { |
| 220 | C<int>::Enum x; // expected-warning {{'Enum' is deprecated}} |
Fariborz Jahanian | 39b4fc8 | 2011-11-28 19:45:58 +0000 | [diff] [blame] | 221 | x = C<int>::c0; // expected-warning {{'c0' is deprecated}} |
John McCall | 5b629aa | 2010-10-22 23:36:17 +0000 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | template <class T> struct D { |
| 225 | enum Enum { |
| 226 | d0, |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 227 | d1 __attribute__((deprecated)), // expected-note {{declared here}} |
John McCall | 5b629aa | 2010-10-22 23:36:17 +0000 | [diff] [blame] | 228 | }; |
| 229 | }; |
| 230 | void testD() { |
| 231 | D<int>::Enum x; |
| 232 | x = D<int>::d0; |
| 233 | x = D<int>::d1; // expected-warning {{'d1' is deprecated}} |
| 234 | } |
| 235 | } |