19109bf10d50d3b5aa57205db1b8e38a31e3ae477Richard Smith// RUN: %clang_cc1 -std=c++98 %s -Wdeprecated -verify -triple x86_64-linux-gnu 29109bf10d50d3b5aa57205db1b8e38a31e3ae477Richard Smith// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -triple x86_64-linux-gnu 39109bf10d50d3b5aa57205db1b8e38a31e3ae477Richard Smith// RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu 479f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith 59109bf10d50d3b5aa57205db1b8e38a31e3ae477Richard Smith// RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS 658df0426944c1bf8a80b6935bbea3815fc506474Richard Smith 76b759f4d3c8bce0fe1f416953ef790c68e7c30b2Richard Smith#include "Inputs/register.h" 86b759f4d3c8bce0fe1f416953ef790c68e7c30b2Richard Smith 979f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smithvoid f() throw(); 1079f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smithvoid g() throw(int); 1179f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smithvoid h() throw(...); 1279f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith#if __cplusplus >= 201103L 1379f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith// expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept' instead}} 1479f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith// expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept(false)' instead}} 1579f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith// expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept(false)' instead}} 1679f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith#endif 1779f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith 1879f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smithvoid stuff() { 1979f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith register int n; 2058df0426944c1bf8a80b6935bbea3815fc506474Richard Smith#if __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS) 2179f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith // expected-warning@-2 {{'register' storage class specifier is deprecated}} 2279f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith#endif 2379f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith 249109bf10d50d3b5aa57205db1b8e38a31e3ae477Richard Smith register int m asm("rbx"); // no-warning 259109bf10d50d3b5aa57205db1b8e38a31e3ae477Richard Smith 266b759f4d3c8bce0fe1f416953ef790c68e7c30b2Richard Smith int k = to_int(n); // no-warning 276b759f4d3c8bce0fe1f416953ef790c68e7c30b2Richard Smith 2879f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith bool b; 2979f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith ++b; // expected-warning {{incrementing expression of type bool is deprecated}} 3079f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith 3179f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith // FIXME: This is ill-formed in C++11. 3279f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith char *p = "foo"; // expected-warning {{conversion from string literal to 'char *' is deprecated}} 3379f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith} 3479f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith 3579f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smithstruct S { int n; }; 3679f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smithstruct T : private S { 371b2209fd149436c98e73d4b8667b40b5f4b974cdRichard Smith S::n; 381b2209fd149436c98e73d4b8667b40b5f4b974cdRichard Smith#if __cplusplus < 201103L 391b2209fd149436c98e73d4b8667b40b5f4b974cdRichard Smith // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} 401b2209fd149436c98e73d4b8667b40b5f4b974cdRichard Smith#else 411b2209fd149436c98e73d4b8667b40b5f4b974cdRichard Smith // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} 421b2209fd149436c98e73d4b8667b40b5f4b974cdRichard Smith#endif 4379f4bb7aad1b7c53f8a3bc43d89de0efdef8286dRichard Smith}; 4436155c14b691720ee3e94bfe99886229650bbfb5Richard Smith 4536155c14b691720ee3e94bfe99886229650bbfb5Richard Smith#if __cplusplus >= 201103L 4636155c14b691720ee3e94bfe99886229650bbfb5Richard Smithnamespace DeprecatedCopy { 4736155c14b691720ee3e94bfe99886229650bbfb5Richard Smith struct Assign { 4836155c14b691720ee3e94bfe99886229650bbfb5Richard Smith Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-declared copy assignment operator}} 4936155c14b691720ee3e94bfe99886229650bbfb5Richard Smith }; 506698be8a6930730df5e61c941197e72682196187Richard Smith Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'Assign' first required here}} 5136155c14b691720ee3e94bfe99886229650bbfb5Richard Smith 5236155c14b691720ee3e94bfe99886229650bbfb5Richard Smith struct Ctor { 5336155c14b691720ee3e94bfe99886229650bbfb5Richard Smith Ctor(); 5436155c14b691720ee3e94bfe99886229650bbfb5Richard Smith Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-declared copy constructor}} 5536155c14b691720ee3e94bfe99886229650bbfb5Richard Smith }; 5636155c14b691720ee3e94bfe99886229650bbfb5Richard Smith Ctor b1, b2; 576698be8a6930730df5e61c941197e72682196187Richard Smith void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'Ctor' first required here}} 5836155c14b691720ee3e94bfe99886229650bbfb5Richard Smith 5936155c14b691720ee3e94bfe99886229650bbfb5Richard Smith struct Dtor { 6036155c14b691720ee3e94bfe99886229650bbfb5Richard Smith ~Dtor(); 6136155c14b691720ee3e94bfe99886229650bbfb5Richard Smith // expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-declared destructor}} 6236155c14b691720ee3e94bfe99886229650bbfb5Richard Smith // expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-declared destructor}} 6336155c14b691720ee3e94bfe99886229650bbfb5Richard Smith }; 646698be8a6930730df5e61c941197e72682196187Richard Smith Dtor c1, c2(c1); // expected-note {{implicit copy constructor for 'Dtor' first required here}} 656698be8a6930730df5e61c941197e72682196187Richard Smith void g() { c1 = c2; } // expected-note {{implicit copy assignment operator for 'Dtor' first required here}} 6636155c14b691720ee3e94bfe99886229650bbfb5Richard Smith} 6736155c14b691720ee3e94bfe99886229650bbfb5Richard Smith#endif 68