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