| 1 |
// RUN: %clang_cc1 -std=c++1y -verify %s |
| 2 |
|
| 3 |
class [[deprecated]] C {}; // expected-note {{'C' has been explicitly marked deprecated here}} |
| 4 |
C c; // expected-warning {{'C' is deprecated}} |
| 5 |
|
| 6 |
typedef int t [[deprecated]]; // expected-note {{'t' has been explicitly marked deprecated here}} |
| 7 |
t x = 42; // expected-warning {{'t' is deprecated}} |
| 8 |
|
| 9 |
[[deprecated]] int old = 42; // expected-note {{'old' has been explicitly marked deprecated here}} |
| 10 |
int use = old; // expected-warning {{'old' is deprecated}} |
| 11 |
|
| 12 |
struct S { [[deprecated]] int member = 42; } s; // expected-note {{'member' has been explicitly marked deprecated here}} |
| 13 |
int use2 = s.member; // expected-warning {{'member' is deprecated}} |
| 14 |
|
| 15 |
[[deprecated]] int f() { return 42; } // expected-note {{'f' has been explicitly marked deprecated here}} |
| 16 |
int use3 = f(); // expected-warning {{'f' is deprecated}} |
| 17 |
|
| 18 |
enum [[deprecated]] e { E }; // expected-note {{'e' has been explicitly marked deprecated here}} |
| 19 |
e my_enum; // expected-warning {{'e' is deprecated}} |
| 20 |
|
| 21 |
template <typename T> class X {}; |
| 22 |
template <> class [[deprecated]] X<int> {}; // expected-note {{'X<int>' has been explicitly marked deprecated here}} |
| 23 |
X<char> x1; |
| 24 |
X<int> x2; // expected-warning {{'X<int>' is deprecated}} |
| 25 |
|
| 26 |
template <typename T> class [[deprecated]] X2 {}; //expected-note {{'X2<char>' has been explicitly marked deprecated here}} |
| 27 |
template <> class X2<int> {}; |
| 28 |
X2<char> x3; // expected-warning {{'X2<char>' is deprecated}} |
| 29 |
X2<int> x4; // No warning, the specialization removes it. |
| 30 |
|
| 31 |
template <typename T> class [[deprecated]] X3; //expected-note {{'X3<char>' has been explicitly marked deprecated here}} |
| 32 |
template <> class X3<int>; |
| 33 |
X3<char> *x5; // expected-warning {{'X3<char>' is deprecated}} |
| 34 |
X3<int> *x6; // No warning, the specialization removes it. |
| 35 |
|
| 36 |
template <typename T> struct A; |
| 37 |
A<int> *p; |
| 38 |
template <typename T> struct [[deprecated]] A;//expected-note {{'A<int>' has been explicitly marked deprecated here}} expected-note {{'A<float>' has been explicitly marked deprecated here}} |
| 39 |
A<int> *q; // expected-warning {{'A<int>' is deprecated}} |
| 40 |
A<float> *r; // expected-warning {{'A<float>' is deprecated}} |
| 41 |
|
| 42 |
template <typename T> struct B; |
| 43 |
B<int> *p2; |
| 44 |
template <typename T> struct [[deprecated]] B;//expected-note {{'B<int>' has been explicitly marked deprecated here}} expected-note {{'B<float>' has been explicitly marked deprecated here}} |
| 45 |
B<int> *q2; // expected-warning {{'B<int>' is deprecated}} |
| 46 |
B<float> *r2; // expected-warning {{'B<float>' is deprecated}} |
| 47 |
|
| 48 |
template <typename T> |
| 49 |
T some_func(T t) { |
| 50 |
struct [[deprecated]] FunS{}; // expected-note {{'FunS' has been explicitly marked deprecated here}} |
| 51 |
FunS f;// expected-warning {{'FunS' is deprecated}} |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
template <typename T> |
| 56 |
[[deprecated]]T some_func2(T t) { |
| 57 |
struct FunS2{}; |
| 58 |
FunS2 f;// No warning, entire function is deprecated, so usage here should be fine. |
| 59 |
|
| 60 |
} |
| 61 |
|
| 62 |
namespace GH58547 { |
| 63 |
struct A { |
| 64 |
using ta [[deprecated]] = int; // expected-note 2{{marked deprecated here}} |
| 65 |
}; |
| 66 |
|
| 67 |
using t1 = typename A::ta; // expected-warning {{'ta' is deprecated}} |
| 68 |
|
| 69 |
template <class B1> struct B { |
| 70 |
using tb = typename B1::ta; // expected-warning {{'ta' is deprecated}} |
| 71 |
}; |
| 72 |
|
| 73 |
template struct B<A>; // expected-note {{requested here}} |
| 74 |
} // namespace GH58547 |
| 75 |
|
| 76 |
|
| 77 |
namespace GH44496 { |
| 78 |
|
| 79 |
|
| 80 |
template <typename T> |
| 81 |
class function { }; |
| 82 |
template <typename A> |
| 83 |
class __attribute__((deprecated)) function<void(A)> { }; |
| 84 |
// expected-note@-1 {{'function<void (int)>' has been explicitly marked deprecated here}} |
| 85 |
|
| 86 |
void test() { |
| 87 |
[[maybe_unused]] function<void(int)> f; // expected-warning{{'function<void (int)>' is deprecated}} |
| 88 |
} |
| 89 |
|
| 90 |
template <class> struct my_template { |
| 91 |
using type = void; |
| 92 |
}; |
| 93 |
|
| 94 |
template <class T> |
| 95 |
struct [[deprecated("primary")]] deprecated { // #deprecated-primary-marked-here |
| 96 |
using type = T; |
| 97 |
}; |
| 98 |
|
| 99 |
template <class T> |
| 100 |
struct my_template<volatile T> : deprecated<T> {}; // #deprecated-primary-base |
| 101 |
|
| 102 |
template <class T> |
| 103 |
struct [[deprecated("specialization")]] my_template<const T> : deprecated<const T> {}; // #my_template-explicit-here |
| 104 |
|
| 105 |
|
| 106 |
template <class T> using my_template_t = typename my_template<T>::type; // #deprecated-my-template-alias |
| 107 |
|
| 108 |
// We cannot warn on X because no instantiation has taken place yet |
| 109 |
using X = my_template<volatile int>; |
| 110 |
|
| 111 |
// Because we already warn on the attribute on the plimary template, we ignore the attribute on the specialization |
| 112 |
using Y = my_template_t<const int>; |
| 113 |
// expected-warning@#deprecated-primary-base {{'deprecated<int>' is deprecated: primary}} \ |
| 114 |
// expected-note@-1 {{in instantiation of template type alias}} \ |
| 115 |
// expected-note@#deprecated-primary-marked-here {{has been explicitly marked deprecated here}} |
| 116 |
|
| 117 |
using Z = my_template_t<volatile int>; |
| 118 |
// expected-warning@#deprecated-my-template-alias {{'my_template<const int>' is deprecated: specialization}} \ |
| 119 |
// expected-note@#my_template-explicit-here {{'my_template<const int>' has been explicitly marked deprecated here}} \ |
| 120 |
// expected-note@#deprecated-my-template-alias {{in instantiation of template class 'GH44496::my_template<volatile int>' requested here}} \ |
| 121 |
// expected-note@-1 {{in instantiation of template type alias 'my_template_t' requested here}} |
| 122 |
|
| 123 |
template <class T> |
| 124 |
struct primary_not_deprecated { |
| 125 |
using type = T; |
| 126 |
}; |
| 127 |
template <class T> |
| 128 |
struct [[deprecated("specialization")]] primary_not_deprecated<volatile T> : deprecated<T> {}; |
| 129 |
// expected-note@-1 {{'primary_not_deprecated<volatile int>' has been explicitly marked deprecated here}} |
| 130 |
|
| 131 |
// We cannot warn on S1 because no instantiation has taken place yet |
| 132 |
using S1 = primary_not_deprecated<volatile int>; |
| 133 |
|
| 134 |
|
| 135 |
using S2 = primary_not_deprecated<volatile int>; |
| 136 |
|
| 137 |
X x; |
| 138 |
Z z; |
| 139 |
S2 s2; |
| 140 |
// expected-warning@-1 {{'primary_not_deprecated<volatile int>' is deprecated: specialization}} |
| 141 |
} |