| 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 | |
| 6 | // RUN: %clang_cc1 -std=c++14 %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++17 does not allow dynamic exception specifications}} expected-note@-4 {{use 'noexcept(false)' instead}} |
| 16 | // expected-error@-4 {{ISO C++17 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(register int q) { |
| 24 | #if __cplusplus > 201402L |
| 25 | // expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}} |
| 26 | #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS) |
| 27 | // expected-warning@-4 {{'register' storage class specifier is deprecated}} |
| 28 | #endif |
| 29 | register int n; |
| 30 | #if __cplusplus > 201402L |
| 31 | // expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}} |
| 32 | #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS) |
| 33 | // expected-warning@-4 {{'register' storage class specifier is deprecated}} |
| 34 | #endif |
| 35 | |
| 36 | register int m asm("rbx"); // no-warning |
| 37 | |
| 38 | int k = to_int(n); // no-warning |
| 39 | bool b; |
| 40 | ++b; |
| 41 | #if __cplusplus > 201402L |
| 42 | // expected-error@-2 {{ISO C++17 does not allow incrementing expression of type bool}} |
| 43 | #else |
| 44 | // expected-warning@-4 {{incrementing expression of type bool is deprecated}} |
| 45 | #endif |
| 46 | |
| 47 | b++; |
| 48 | #if __cplusplus > 201402L |
| 49 | // expected-error@-2 {{ISO C++17 does not allow incrementing expression of type bool}} |
| 50 | #else |
| 51 | // expected-warning@-4 {{incrementing expression of type bool is deprecated}} |
| 52 | #endif |
| 53 | |
| 54 | char *p = "foo"; |
| 55 | #if __cplusplus < 201103L |
| 56 | // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}} |
| 57 | #else |
| 58 | // expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}} |
| 59 | #endif |
| 60 | } |
| 61 | |
| 62 | struct S { int n; void operator+(int); }; |
| 63 | struct T : private S { |
| 64 | S::n; |
| 65 | #if __cplusplus < 201103L |
| 66 | // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} |
| 67 | #else |
| 68 | // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} |
| 69 | #endif |
| 70 | S::operator+; |
| 71 | #if __cplusplus < 201103L |
| 72 | // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} |
| 73 | #else |
| 74 | // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} |
| 75 | #endif |
| 76 | }; |
| 77 | |
| 78 | #if __cplusplus >= 201103L |
| 79 | namespace DeprecatedCopy { |
| 80 | struct Assign { |
| 81 | Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-declared copy assignment operator}} |
| 82 | }; |
| 83 | Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'DeprecatedCopy::Assign' first required here}} |
| 84 | |
| 85 | struct Ctor { |
| 86 | Ctor(); |
| 87 | Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-declared copy constructor}} |
| 88 | }; |
| 89 | Ctor b1, b2; |
| 90 | void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Ctor' first required here}} |
| 91 | |
| 92 | struct Dtor { |
| 93 | ~Dtor(); |
| 94 | // expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-declared destructor}} |
| 95 | // expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-declared destructor}} |
| 96 | }; |
| 97 | Dtor c1, c2(c1); // expected-note {{implicit copy constructor for 'DeprecatedCopy::Dtor' first required here}} |
| 98 | void g() { c1 = c2; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Dtor' first required here}} |
| 99 | } |
| 100 | #endif |
| 101 | |
| 102 | # 1 "/usr/include/system-header.h" 1 3 |
| 103 | void system_header_function(void) throw(); |
| 104 | |