1 // RUN: %clang_cc1 -std=c++98 %s -Wdeprecated -verify -triple x86_64-linux-gnu
2 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -triple x86_64-linux-gnu
3 // RUN: %clang_cc1 -std=c++14 %s -Wdeprecated -verify -triple x86_64-linux-gnu
4 // RUN: %clang_cc1 -std=c++17 %s -Wdeprecated -verify -triple x86_64-linux-gnu
5 // RUN: %clang_cc1 -std=c++2a %s -Wdeprecated -verify -triple x86_64-linux-gnu
6 
7 // RUN: %clang_cc1 -std=c++14 %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS
8 
9 #include "Inputs/register.h"
10 
11 void g() throw();
12 void h() throw(int);
13 void i() throw(...);
14 #if __cplusplus > 201402L
15 // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept' instead}}
16 // expected-error@-4 {{ISO C++17 does not allow dynamic exception specifications}} expected-note@-4 {{use 'noexcept(false)' instead}}
17 // expected-error@-4 {{ISO C++17 does not allow dynamic exception specifications}} expected-note@-4 {{use 'noexcept(false)' instead}}
18 #elif __cplusplus >= 201103L
19 // expected-warning@-8 {{dynamic exception specifications are deprecated}} expected-note@-8 {{use 'noexcept' instead}}
20 // expected-warning@-8 {{dynamic exception specifications are deprecated}} expected-note@-8 {{use 'noexcept(false)' instead}}
21 // expected-warning@-8 {{dynamic exception specifications are deprecated}} expected-note@-8 {{use 'noexcept(false)' instead}}
22 #endif
23 
24 void stuff(register int q) {
25 #if __cplusplus > 201402L
26   // expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
27 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
28   // expected-warning@-4 {{'register' storage class specifier is deprecated}}
29 #endif
30   register int n;
31 #if __cplusplus > 201402L
32   // expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
33 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
34   // expected-warning@-4 {{'register' storage class specifier is deprecated}}
35 #endif
36 
37   register int m asm("rbx"); // no-warning
38 
39   int k = to_int(n); // no-warning
40   bool b;
41   ++b;
42 #if __cplusplus > 201402L
43   // expected-error@-2 {{ISO C++17 does not allow incrementing expression of type bool}}
44 #else
45   // expected-warning@-4 {{incrementing expression of type bool is deprecated}}
46 #endif
47 
48   b++;
49 #if __cplusplus > 201402L
50   // expected-error@-2 {{ISO C++17 does not allow incrementing expression of type bool}}
51 #else
52   // expected-warning@-4 {{incrementing expression of type bool is deprecated}}
53 #endif
54 
55   char *p = "foo";
56 #if __cplusplus < 201103L
57   // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}
58 #else
59   // expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
60 #endif
61 }
62 
63 struct S { int n; void operator+(int); };
64 struct T : private S {
65   S::n;
66 #if __cplusplus < 201103L
67   // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
68 #else
69   // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
70 #endif
71   S::operator+;
72 #if __cplusplus < 201103L
73   // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
74 #else
75   // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
76 #endif
77 };
78 
79 #if __cplusplus >= 201103L
80 namespace DeprecatedCopy {
81   struct Assign {
82     Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-declared copy assignment operator}}
83   };
84   Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'DeprecatedCopy::Assign' first required here}}
85 
86   struct Ctor {
87     Ctor();
88     Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-declared copy constructor}}
89   };
90   Ctor b1, b2;
91   void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Ctor' first required here}}
92 
93   struct Dtor {
94     ~Dtor();
95     // expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-declared destructor}}
96     // expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-declared destructor}}
97   };
98   Dtor c1, c2(c1); // expected-note {{implicit copy constructor for 'DeprecatedCopy::Dtor' first required here}}
99   void g() { c1 = c2; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Dtor' first required here}}
100 }
101 #endif
102 
103 struct X {
104   friend int operator,(X, X);
105   void operator[](int);
106 };
107 void array_index_comma() {
108   int arr[123];
109   (void)arr[(void)1, 2];
110   (void)arr[X(), X()];
111   X()[(void)1, 2];
112   X()[X(), X()];
113 #if __cplusplus > 201703L
114   // expected-warning@-5 {{deprecated}}
115   // expected-warning@-5 {{deprecated}}
116   // expected-warning@-5 {{deprecated}}
117   // expected-warning@-5 {{deprecated}}
118 #endif
119 
120   (void)arr[((void)1, 2)];
121   (void)arr[(X(), X())];
122   (void)((void)1,2)[arr];
123   (void)(X(), X())[arr];
124   X()[((void)1, 2)];
125   X()[(X(), X())];
126 }
127 
128 # 1 "/usr/include/system-header.h" 1 3
129 void system_header_function(void) throw();
130