2013-06-16 04:17:46 +08:00
// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat-pedantic -verify %s -DCXX1Y2
// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat -Werror %s -DCXX1Y2
2011-10-15 09:18:56 +08:00
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s
2011-10-15 13:09:34 +08:00
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s
2014-09-18 10:09:53 +08:00
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s -DCXX98
2011-10-15 09:18:56 +08:00
2013-06-16 04:17:46 +08:00
// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s -Wno-c++98-c++11-compat-pedantic -DCXX1Y2
2013-05-17 11:11:25 +08:00
2011-10-15 09:18:56 +08:00
// -Wc++98-compat-pedantic warns on C++11 features which we accept without a
// warning in C++98 mode.
# line 32767 // ok
# line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}}
# define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}}
2012-06-23 07:59:08 +08:00
VA_MACRO ( , x ) // expected-warning {{empty macro arguments are incompatible with C++98}}
2011-10-15 13:09:34 +08:00
; // expected-warning {{extra ';' outside of a function is incompatible with C++98}}
enum Enum {
Enum_value , // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}}
} ;
2011-10-19 04:49:44 +08:00
void * dlsym ( ) ;
void ( * FnPtr ) ( ) = ( void ( * ) ( ) ) dlsym ( ) ; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
void * FnVoidPtr = ( void * ) & dlsym ; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
struct ConvertToInt {
operator int ( ) ;
} ;
2013-06-16 04:17:46 +08:00
int * ArraySizeConversion = new int [ ConvertToInt ( ) ] ;
# ifdef CXX1Y2
2013-06-18 09:27:47 +08:00
// expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}}
2013-06-16 04:17:46 +08:00
# else
// expected-warning@-4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}
# endif
2011-10-21 02:35:58 +08:00
template < typename T > class ExternTemplate { } ;
extern template class ExternTemplate < int > ; // expected-warning {{extern templates are incompatible with C++98}}
2012-09-25 02:19:21 +08:00
long long ll1 = // expected-warning {{'long long' is incompatible with C++98}}
- 42LL ; // expected-warning {{'long long' is incompatible with C++98}}
unsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}}
42ULL ; // expected-warning {{'long long' is incompatible with C++98}}
2013-04-20 04:47:20 +08:00
int k = 0b1001 ;
# ifdef CXX1Y
2014-08-19 23:55:55 +08:00
// expected-warning@-2 {{binary integer literals are incompatible with C++ standards before C++14}}
2013-04-20 04:47:20 +08:00
# endif
2014-09-18 10:09:53 +08:00
namespace CopyCtorIssues {
struct Private {
Private ( ) ;
private :
Private ( const Private & ) ; // expected-note {{declared private here}}
} ;
struct NoViable {
NoViable ( ) ;
NoViable ( NoViable & ) ; // expected-note {{not viable}}
} ;
struct Ambiguous {
Ambiguous ( ) ;
Ambiguous ( const Ambiguous & , int = 0 ) ; // expected-note {{candidate}}
Ambiguous ( const Ambiguous & , double = 0 ) ; // expected-note {{candidate}}
} ;
struct Deleted {
Private p ; // expected-note {{implicitly deleted}}
} ;
const Private & a = Private ( ) ; // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
const NoViable & b = NoViable ( ) ; // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
# if !CXX98
const Ambiguous & c = Ambiguous ( ) ; // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}}
# endif
const Deleted & d = Deleted ( ) ; // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}
}