xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/deprecated.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++98 %s -Wdeprecated -verify -triple x86_64-linux-gnu
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -triple x86_64-linux-gnu
3*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc #include "Inputs/register.h"
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc void f() throw();
10*f4a2713aSLionel Sambuc void g() throw(int);
11*f4a2713aSLionel Sambuc void h() throw(...);
12*f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
13*f4a2713aSLionel Sambuc // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept' instead}}
14*f4a2713aSLionel Sambuc // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept(false)' instead}}
15*f4a2713aSLionel Sambuc // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept(false)' instead}}
16*f4a2713aSLionel Sambuc #endif
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc void stuff() {
19*f4a2713aSLionel Sambuc   register int n;
20*f4a2713aSLionel Sambuc #if __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
21*f4a2713aSLionel Sambuc   // expected-warning@-2 {{'register' storage class specifier is deprecated}}
22*f4a2713aSLionel Sambuc #endif
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc   register int m asm("rbx"); // no-warning
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc   int k = to_int(n); // no-warning
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc   bool b;
29*f4a2713aSLionel Sambuc   ++b; // expected-warning {{incrementing expression of type bool is deprecated}}
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc   // FIXME: This is ill-formed in C++11.
32*f4a2713aSLionel Sambuc   char *p = "foo"; // expected-warning {{conversion from string literal to 'char *' is deprecated}}
33*f4a2713aSLionel Sambuc }
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc struct S { int n; };
36*f4a2713aSLionel Sambuc struct T : private S {
37*f4a2713aSLionel Sambuc   S::n;
38*f4a2713aSLionel Sambuc #if __cplusplus < 201103L
39*f4a2713aSLionel Sambuc   // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
40*f4a2713aSLionel Sambuc #else
41*f4a2713aSLionel Sambuc   // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
42*f4a2713aSLionel Sambuc #endif
43*f4a2713aSLionel Sambuc };
44*f4a2713aSLionel Sambuc 
45*f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
46*f4a2713aSLionel Sambuc namespace DeprecatedCopy {
47*f4a2713aSLionel Sambuc   struct Assign {
48*f4a2713aSLionel Sambuc     Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-declared copy assignment operator}}
49*f4a2713aSLionel Sambuc   };
50*f4a2713aSLionel Sambuc   Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'Assign' first required here}}
51*f4a2713aSLionel Sambuc 
52*f4a2713aSLionel Sambuc   struct Ctor {
53*f4a2713aSLionel Sambuc     Ctor();
54*f4a2713aSLionel Sambuc     Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-declared copy constructor}}
55*f4a2713aSLionel Sambuc   };
56*f4a2713aSLionel Sambuc   Ctor b1, b2;
57*f4a2713aSLionel Sambuc   void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'Ctor' first required here}}
58*f4a2713aSLionel Sambuc 
59*f4a2713aSLionel Sambuc   struct Dtor {
60*f4a2713aSLionel Sambuc     ~Dtor();
61*f4a2713aSLionel Sambuc     // expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-declared destructor}}
62*f4a2713aSLionel Sambuc     // expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-declared destructor}}
63*f4a2713aSLionel Sambuc   };
64*f4a2713aSLionel Sambuc   Dtor c1, c2(c1); // expected-note {{implicit copy constructor for 'Dtor' first required here}}
65*f4a2713aSLionel Sambuc   void g() { c1 = c2; } // expected-note {{implicit copy assignment operator for 'Dtor' first required here}}
66*f4a2713aSLionel Sambuc }
67*f4a2713aSLionel Sambuc #endif
68