Clang Project

clang_source_code/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
1// RUN: %clang_cc1 -std=c++1y -verify %s
2
3class [[deprecated]] C {}; // expected-note {{'C' has been explicitly marked deprecated here}}
4C c; // expected-warning {{'C' is deprecated}}
5
6typedef int t [[deprecated]]; // expected-note {{'t' has been explicitly marked deprecated here}}
7t x = 42; // expected-warning {{'t' is deprecated}}
8
9[[deprecated]] int old = 42; // expected-note {{'old' has been explicitly marked deprecated here}}
10int use = old; // expected-warning {{'old' is deprecated}}
11
12struct S { [[deprecated]] int member = 42; } s; // expected-note {{'member' has been explicitly marked deprecated here}}
13int use2 = s.member; // expected-warning {{'member' is deprecated}}
14
15[[deprecated]] int f() { return 42; } // expected-note {{'f' has been explicitly marked deprecated here}}
16int use3 = f(); // expected-warning {{'f' is deprecated}}
17
18enum [[deprecated]] e { E }; // expected-note {{'e' has been explicitly marked deprecated here}}
19e my_enum; // expected-warning {{'e' is deprecated}}
20
21template <typename T> class X {};
22template <> class [[deprecated]] X<int> {}; // expected-note {{'X<int>' has been explicitly marked deprecated here}}
23X<char> x1;
24X<int> x2; // expected-warning {{'X<int>' is deprecated}}
25
26template <typename T> class [[deprecated]] X2 {}; //expected-note {{'X2<char>' has been explicitly marked deprecated here}}
27template <> class X2<int> {};
28X2<char> x3; // expected-warning {{'X2<char>' is deprecated}}
29X2<int> x4; // No warning, the specialization removes it.
30
31template <typename T> class [[deprecated]] X3; //expected-note {{'X3<char>' has been explicitly marked deprecated here}}
32template <> class X3<int>;
33X3<char> *x5; // expected-warning {{'X3<char>' is deprecated}}
34X3<int> *x6; // No warning, the specialization removes it.
35
36template <typename T> struct A;
37A<int> *p;
38template <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}}
39A<int> *q; // expected-warning {{'A<int>' is deprecated}}
40A<float> *r; // expected-warning {{'A<float>' is deprecated}}
41
42template <typename T> struct B;
43B<int> *p2;
44template <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}}
45B<int> *q2; // expected-warning {{'B<int>' is deprecated}}
46B<float> *r2; // expected-warning {{'B<float>' is deprecated}}
47
48template <typename T> 
49T 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
55template <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