blob: 5fcf2130d36f0a056554d714c624d17c03308912 [file] [log] [blame]
Richard Smith9109bf12013-06-17 01:34:01 +00001// 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 Smith79f4bb72013-06-13 02:02:51 +00004
Richard Smith9109bf12013-06-17 01:34:01 +00005// RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS
Richard Smith58df0422013-06-17 00:01:58 +00006
Richard Smith6b759f42013-06-14 21:05:24 +00007#include "Inputs/register.h"
8
Richard Smith79f4bb72013-06-13 02:02:51 +00009void f() throw();
10void g() throw(int);
11void 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
18void stuff() {
19 register int n;
Richard Smith58df0422013-06-17 00:01:58 +000020#if __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
Richard Smith79f4bb72013-06-13 02:02:51 +000021 // expected-warning@-2 {{'register' storage class specifier is deprecated}}
22#endif
23
Richard Smith9109bf12013-06-17 01:34:01 +000024 register int m asm("rbx"); // no-warning
25
Richard Smith6b759f42013-06-14 21:05:24 +000026 int k = to_int(n); // no-warning
Richard Smith79f4bb72013-06-13 02:02:51 +000027 bool b;
28 ++b; // expected-warning {{incrementing expression of type bool is deprecated}}
29
Stephen Hines651f13c2014-04-23 16:59:28 -070030 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 Smith79f4bb72013-06-13 02:02:51 +000036}
37
Stephen Hines176edba2014-12-01 14:53:08 -080038struct S { int n; void operator+(int); };
Richard Smith79f4bb72013-06-13 02:02:51 +000039struct T : private S {
Richard Smith1b2209f2013-06-13 02:12:17 +000040 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 Hines176edba2014-12-01 14:53:08 -080046 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 Smith79f4bb72013-06-13 02:02:51 +000052};
Richard Smith36155c12013-06-13 03:23:42 +000053
54#if __cplusplus >= 201103L
55namespace 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 Smith6698be82013-06-13 03:34:55 +000059 Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'Assign' first required here}}
Richard Smith36155c12013-06-13 03:23:42 +000060
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 Smith6698be82013-06-13 03:34:55 +000066 void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'Ctor' first required here}}
Richard Smith36155c12013-06-13 03:23:42 +000067
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 Smith6698be82013-06-13 03:34:55 +000073 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 Smith36155c12013-06-13 03:23:42 +000075}
76#endif