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