1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat-pedantic -verify %s -DCXX1Y2 2*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat -Werror %s -DCXX1Y2 3*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s 4*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s 5*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s -DCXX98 6*67e74705SXin Li 7*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s -Wno-c++98-c++11-compat-pedantic -DCXX1Y2 8*67e74705SXin Li 9*67e74705SXin Li // -Wc++98-compat-pedantic warns on C++11 features which we accept without a 10*67e74705SXin Li // warning in C++98 mode. 11*67e74705SXin Li 12*67e74705SXin Li #line 32767 // ok 13*67e74705SXin Li #line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}} 14*67e74705SXin Li 15*67e74705SXin Li #define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}} 16*67e74705SXin Li VA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}} 17*67e74705SXin Li 18*67e74705SXin Li ; // expected-warning {{extra ';' outside of a function is incompatible with C++98}} 19*67e74705SXin Li 20*67e74705SXin Li enum Enum { 21*67e74705SXin Li Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}} 22*67e74705SXin Li }; 23*67e74705SXin Li 24*67e74705SXin Li template<typename T> struct InstantiationAfterSpecialization {}; 25*67e74705SXin Li template<> struct InstantiationAfterSpecialization<int> {}; // expected-note {{here}} 26*67e74705SXin Li template struct InstantiationAfterSpecialization<int>; // expected-warning {{explicit instantiation of 'InstantiationAfterSpecialization<int>' that occurs after an explicit specialization is incompatible with C++98}} 27*67e74705SXin Li 28*67e74705SXin Li void *dlsym(); 29*67e74705SXin Li void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}} 30*67e74705SXin Li void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}} 31*67e74705SXin Li 32*67e74705SXin Li struct ConvertToInt { 33*67e74705SXin Li operator int(); 34*67e74705SXin Li }; 35*67e74705SXin Li int *ArraySizeConversion = new int[ConvertToInt()]; 36*67e74705SXin Li #ifdef CXX1Y2 37*67e74705SXin Li // expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}} 38*67e74705SXin Li #else 39*67e74705SXin Li // expected-warning@-4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}} 40*67e74705SXin Li #endif 41*67e74705SXin Li 42*67e74705SXin Li template<typename T> class ExternTemplate {}; 43*67e74705SXin Li extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}} 44*67e74705SXin Li 45*67e74705SXin Li long long ll1 = // expected-warning {{'long long' is incompatible with C++98}} 46*67e74705SXin Li -42LL; // expected-warning {{'long long' is incompatible with C++98}} 47*67e74705SXin Li unsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}} 48*67e74705SXin Li 42ULL; // expected-warning {{'long long' is incompatible with C++98}} 49*67e74705SXin Li 50*67e74705SXin Li int k = 0b1001; 51*67e74705SXin Li #ifdef CXX1Y 52*67e74705SXin Li // expected-warning@-2 {{binary integer literals are incompatible with C++ standards before C++14}} 53*67e74705SXin Li #endif 54*67e74705SXin Li 55*67e74705SXin Li namespace CopyCtorIssues { 56*67e74705SXin Li struct Private { 57*67e74705SXin Li Private(); 58*67e74705SXin Li private: 59*67e74705SXin Li Private(const Private&); // expected-note {{declared private here}} 60*67e74705SXin Li }; 61*67e74705SXin Li struct NoViable { 62*67e74705SXin Li NoViable(); 63*67e74705SXin Li NoViable(NoViable&); // expected-note {{not viable}} 64*67e74705SXin Li }; 65*67e74705SXin Li struct Ambiguous { 66*67e74705SXin Li Ambiguous(); 67*67e74705SXin Li Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}} 68*67e74705SXin Li Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}} 69*67e74705SXin Li }; 70*67e74705SXin Li struct Deleted { 71*67e74705SXin Li Private p; // expected-note {{implicitly deleted}} 72*67e74705SXin Li }; 73*67e74705SXin Li 74*67e74705SXin Li 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}} 75*67e74705SXin Li 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}} 76*67e74705SXin Li #if !CXX98 77*67e74705SXin Li 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}} 78*67e74705SXin Li #endif 79*67e74705SXin Li 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}} 80*67e74705SXin Li } 81