2013-06-17 09:34:01 +08:00
// RUN: %clang_cc1 -std=c++98 %s -Wdeprecated -verify -triple x86_64-linux-gnu
// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -triple x86_64-linux-gnu
2017-08-14 06:26:53 +08:00
// RUN: %clang_cc1 -std=c++14 %s -Wdeprecated -verify -triple x86_64-linux-gnu
// RUN: %clang_cc1 -std=c++17 %s -Wdeprecated -verify -triple x86_64-linux-gnu
2013-06-13 10:02:51 +08:00
2017-08-14 06:26:53 +08:00
// RUN: %clang_cc1 -std=c++14 %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS
2013-06-17 08:01:58 +08:00
2013-06-15 05:05:24 +08:00
# include "Inputs/register.h"
2016-10-17 01:54:23 +08:00
void g ( ) throw ( ) ;
void h ( ) throw ( int ) ;
void i ( ) throw ( . . . ) ;
2016-12-08 10:49:07 +08:00
# if __cplusplus > 201402L
2013-06-13 10:02:51 +08:00
// expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept' instead}}
2017-08-14 06:26:53 +08:00
// expected-error@-4 {{ISO C++17 does not allow dynamic exception specifications}} expected-note@-4 {{use 'noexcept(false)' instead}}
// expected-error@-4 {{ISO C++17 does not allow dynamic exception specifications}} expected-note@-4 {{use 'noexcept(false)' instead}}
2016-12-08 10:49:07 +08:00
# elif __cplusplus >= 201103L
// expected-warning@-8 {{dynamic exception specifications are deprecated}} expected-note@-8 {{use 'noexcept' instead}}
// expected-warning@-8 {{dynamic exception specifications are deprecated}} expected-note@-8 {{use 'noexcept(false)' instead}}
// expected-warning@-8 {{dynamic exception specifications are deprecated}} expected-note@-8 {{use 'noexcept(false)' instead}}
2013-06-13 10:02:51 +08:00
# endif
2017-11-02 07:38:37 +08:00
void stuff ( register int q ) {
# if __cplusplus > 201402L
// expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
# elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
// expected-warning@-4 {{'register' storage class specifier is deprecated}}
# endif
2013-06-13 10:02:51 +08:00
register int n ;
2015-11-26 05:34:21 +08:00
# if __cplusplus > 201402L
2017-08-14 06:26:53 +08:00
// expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
2015-11-26 05:34:21 +08:00
# elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
// expected-warning@-4 {{'register' storage class specifier is deprecated}}
2013-06-13 10:02:51 +08:00
# endif
2013-06-17 09:34:01 +08:00
register int m asm ( " rbx " ) ; // no-warning
2013-06-15 05:05:24 +08:00
int k = to_int ( n ) ; // no-warning
2013-06-13 10:02:51 +08:00
bool b ;
2015-11-26 10:16:37 +08:00
+ + b ;
# if __cplusplus > 201402L
2017-08-14 06:26:53 +08:00
// expected-error@-2 {{ISO C++17 does not allow incrementing expression of type bool}}
2015-11-26 10:16:37 +08:00
# else
// expected-warning@-4 {{incrementing expression of type bool is deprecated}}
# endif
b + + ;
# if __cplusplus > 201402L
2017-08-14 06:26:53 +08:00
// expected-error@-2 {{ISO C++17 does not allow incrementing expression of type bool}}
2015-11-26 10:16:37 +08:00
# else
// expected-warning@-4 {{incrementing expression of type bool is deprecated}}
# endif
2013-06-13 10:02:51 +08:00
2014-01-18 05:08:52 +08:00
char * p = " foo " ;
# if __cplusplus < 201103L
// expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}
# else
// expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
# endif
2013-06-13 10:02:51 +08:00
}
2014-09-11 01:03:37 +08:00
struct S { int n ; void operator + ( int ) ; } ;
2013-06-13 10:02:51 +08:00
struct T : private S {
2013-06-13 10:12:17 +08:00
S : : n ;
# if __cplusplus < 201103L
// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
# else
// expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
2014-09-11 01:03:37 +08:00
# endif
S : : operator + ;
# if __cplusplus < 201103L
// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
# else
// expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
2013-06-13 10:12:17 +08:00
# endif
2013-06-13 10:02:51 +08:00
} ;
2013-06-13 11:23:42 +08:00
# if __cplusplus >= 201103L
namespace DeprecatedCopy {
struct Assign {
Assign & operator = ( const Assign & ) ; // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-declared copy assignment operator}}
} ;
2017-05-26 06:47:05 +08:00
Assign a1 , a2 ( a1 ) ; // expected-note {{implicit copy constructor for 'DeprecatedCopy::Assign' first required here}}
2013-06-13 11:23:42 +08:00
struct Ctor {
Ctor ( ) ;
Ctor ( const Ctor & ) ; // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-declared copy constructor}}
} ;
Ctor b1 , b2 ;
2017-05-26 06:47:05 +08:00
void f ( ) { b1 = b2 ; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Ctor' first required here}}
2013-06-13 11:23:42 +08:00
struct Dtor {
~ Dtor ( ) ;
// expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-declared destructor}}
// expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-declared destructor}}
} ;
2017-05-26 06:47:05 +08:00
Dtor c1 , c2 ( c1 ) ; // expected-note {{implicit copy constructor for 'DeprecatedCopy::Dtor' first required here}}
void g ( ) { c1 = c2 ; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Dtor' first required here}}
2013-06-13 11:23:42 +08:00
}
# endif
2017-10-31 02:05:10 +08:00
# 1 " / usr / include / system-header.h" 1 3
void system_header_function ( void ) throw ( ) ;