blob: 75ec0bc4196319b4223a2b1fcd8cd430d3500be4 [file] [log] [blame]
Richard Smith79f4bb72013-06-13 02:02:51 +00001// 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 Smith6b759f42013-06-14 21:05:24 +00005#include "Inputs/register.h"
6
Richard Smith79f4bb72013-06-13 02:02:51 +00007void f() throw();
8void g() throw(int);
9void 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
16void stuff() {
17 register int n;
18#if __cplusplus >= 201103L
19 // expected-warning@-2 {{'register' storage class specifier is deprecated}}
20#endif
21
Richard Smith6b759f42013-06-14 21:05:24 +000022 int k = to_int(n); // no-warning
23
Richard Smith79f4bb72013-06-13 02:02:51 +000024 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
31struct S { int n; };
32struct T : private S {
Richard Smith1b2209f2013-06-13 02:12:17 +000033 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 Smith79f4bb72013-06-13 02:02:51 +000039};
Richard Smith36155c12013-06-13 03:23:42 +000040
41#if __cplusplus >= 201103L
42namespace 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 Smith6698be82013-06-13 03:34:55 +000046 Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'Assign' first required here}}
Richard Smith36155c12013-06-13 03:23:42 +000047
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 Smith6698be82013-06-13 03:34:55 +000053 void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'Ctor' first required here}}
Richard Smith36155c12013-06-13 03:23:42 +000054
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 Smith6698be82013-06-13 03:34:55 +000060 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 Smith36155c12013-06-13 03:23:42 +000062}
63#endif