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++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu 4 // RUN: %clang_cc1 -std=c++1z %s -Wdeprecated -verify -triple x86_64-linux-gnu 5 6 // RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS 7 8 #include "Inputs/register.h" 9 10 void g() throw(); 11 void h() throw(int); 12 void i() throw(...); 13 #if __cplusplus > 201402L 14 // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept' instead}} 15 // expected-error@-4 {{ISO C++1z does not allow dynamic exception specifications}} expected-note@-4 {{use 'noexcept(false)' instead}} 16 // expected-error@-4 {{ISO C++1z does not allow dynamic exception specifications}} expected-note@-4 {{use 'noexcept(false)' instead}} 17 #elif __cplusplus >= 201103L 18 // expected-warning@-8 {{dynamic exception specifications are deprecated}} expected-note@-8 {{use 'noexcept' instead}} 19 // expected-warning@-8 {{dynamic exception specifications are deprecated}} expected-note@-8 {{use 'noexcept(false)' instead}} 20 // expected-warning@-8 {{dynamic exception specifications are deprecated}} expected-note@-8 {{use 'noexcept(false)' instead}} 21 #endif 22 23 void stuff() { 24 register int n; 25 #if __cplusplus > 201402L 26 // expected-error@-2 {{ISO C++1z 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 31 register int m asm("rbx"); // no-warning 32 33 int k = to_int(n); // no-warning 34 bool b; 35 ++b; 36 #if __cplusplus > 201402L 37 // expected-error@-2 {{ISO C++1z does not allow incrementing expression of type bool}} 38 #else 39 // expected-warning@-4 {{incrementing expression of type bool is deprecated}} 40 #endif 41 42 b++; 43 #if __cplusplus > 201402L 44 // expected-error@-2 {{ISO C++1z does not allow incrementing expression of type bool}} 45 #else 46 // expected-warning@-4 {{incrementing expression of type bool is deprecated}} 47 #endif 48 49 char *p = "foo"; 50 #if __cplusplus < 201103L 51 // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}} 52 #else 53 // expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}} 54 #endif 55 } 56 57 struct S { int n; void operator+(int); }; 58 struct T : private S { 59 S::n; 60 #if __cplusplus < 201103L 61 // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} 62 #else 63 // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} 64 #endif 65 S::operator+; 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 }; 72 73 #if __cplusplus >= 201103L 74 namespace DeprecatedCopy { 75 struct Assign { 76 Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-declared copy assignment operator}} 77 }; 78 Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'Assign' first required here}} 79 80 struct Ctor { 81 Ctor(); 82 Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-declared copy constructor}} 83 }; 84 Ctor b1, b2; 85 void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'Ctor' first required here}} 86 87 struct Dtor { 88 ~Dtor(); 89 // expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-declared destructor}} 90 // expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-declared destructor}} 91 }; 92 Dtor c1, c2(c1); // expected-note {{implicit copy constructor for 'Dtor' first required here}} 93 void g() { c1 = c2; } // expected-note {{implicit copy assignment operator for 'Dtor' first required here}} 94 } 95 #endif 96