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