Richard Smith | 9109bf1 | 2013-06-17 01:34:01 +0000 | [diff] [blame] | 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 |
Richard Smith | 79f4bb7 | 2013-06-13 02:02:51 +0000 | [diff] [blame] | 4 | |
Richard Smith | 9109bf1 | 2013-06-17 01:34:01 +0000 | [diff] [blame] | 5 | // RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS |
Richard Smith | 58df042 | 2013-06-17 00:01:58 +0000 | [diff] [blame] | 6 | |
Richard Smith | 6b759f4 | 2013-06-14 21:05:24 +0000 | [diff] [blame] | 7 | #include "Inputs/register.h" |
| 8 | |
Richard Smith | 79f4bb7 | 2013-06-13 02:02:51 +0000 | [diff] [blame] | 9 | void f() throw(); |
| 10 | void g() throw(int); |
| 11 | void h() throw(...); |
| 12 | #if __cplusplus >= 201103L |
| 13 | // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept' instead}} |
| 14 | // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept(false)' instead}} |
| 15 | // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept(false)' instead}} |
| 16 | #endif |
| 17 | |
| 18 | void stuff() { |
| 19 | register int n; |
Richard Smith | 58df042 | 2013-06-17 00:01:58 +0000 | [diff] [blame] | 20 | #if __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS) |
Richard Smith | 79f4bb7 | 2013-06-13 02:02:51 +0000 | [diff] [blame] | 21 | // expected-warning@-2 {{'register' storage class specifier is deprecated}} |
| 22 | #endif |
| 23 | |
Richard Smith | 9109bf1 | 2013-06-17 01:34:01 +0000 | [diff] [blame] | 24 | register int m asm("rbx"); // no-warning |
| 25 | |
Richard Smith | 6b759f4 | 2013-06-14 21:05:24 +0000 | [diff] [blame] | 26 | int k = to_int(n); // no-warning |
Richard Smith | 79f4bb7 | 2013-06-13 02:02:51 +0000 | [diff] [blame] | 27 | bool b; |
| 28 | ++b; // expected-warning {{incrementing expression of type bool is deprecated}} |
| 29 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 30 | char *p = "foo"; |
| 31 | #if __cplusplus < 201103L |
| 32 | // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}} |
| 33 | #else |
| 34 | // expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}} |
| 35 | #endif |
Richard Smith | 79f4bb7 | 2013-06-13 02:02:51 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 38 | struct S { int n; void operator+(int); }; |
Richard Smith | 79f4bb7 | 2013-06-13 02:02:51 +0000 | [diff] [blame] | 39 | struct T : private S { |
Richard Smith | 1b2209f | 2013-06-13 02:12:17 +0000 | [diff] [blame] | 40 | S::n; |
| 41 | #if __cplusplus < 201103L |
| 42 | // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} |
| 43 | #else |
| 44 | // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} |
| 45 | #endif |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 46 | S::operator+; |
| 47 | #if __cplusplus < 201103L |
| 48 | // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} |
| 49 | #else |
| 50 | // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} |
| 51 | #endif |
Richard Smith | 79f4bb7 | 2013-06-13 02:02:51 +0000 | [diff] [blame] | 52 | }; |
Richard Smith | 36155c1 | 2013-06-13 03:23:42 +0000 | [diff] [blame] | 53 | |
| 54 | #if __cplusplus >= 201103L |
| 55 | namespace DeprecatedCopy { |
| 56 | struct Assign { |
| 57 | Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-declared copy assignment operator}} |
| 58 | }; |
Richard Smith | 6698be8 | 2013-06-13 03:34:55 +0000 | [diff] [blame] | 59 | Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'Assign' first required here}} |
Richard Smith | 36155c1 | 2013-06-13 03:23:42 +0000 | [diff] [blame] | 60 | |
| 61 | struct Ctor { |
| 62 | Ctor(); |
| 63 | Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-declared copy constructor}} |
| 64 | }; |
| 65 | Ctor b1, b2; |
Richard Smith | 6698be8 | 2013-06-13 03:34:55 +0000 | [diff] [blame] | 66 | void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'Ctor' first required here}} |
Richard Smith | 36155c1 | 2013-06-13 03:23:42 +0000 | [diff] [blame] | 67 | |
| 68 | struct Dtor { |
| 69 | ~Dtor(); |
| 70 | // expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-declared destructor}} |
| 71 | // expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-declared destructor}} |
| 72 | }; |
Richard Smith | 6698be8 | 2013-06-13 03:34:55 +0000 | [diff] [blame] | 73 | Dtor c1, c2(c1); // expected-note {{implicit copy constructor for 'Dtor' first required here}} |
| 74 | void g() { c1 = c2; } // expected-note {{implicit copy assignment operator for 'Dtor' first required here}} |
Richard Smith | 36155c1 | 2013-06-13 03:23:42 +0000 | [diff] [blame] | 75 | } |
| 76 | #endif |