blob: 50ce6a49002ee5d9bb73d0d8db114dc74969f0ee [file] [log] [blame]
Larisse Voufo539470e2013-06-15 20:17:46 +00001// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat-pedantic -verify %s -DCXX1Y2
2// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat -Werror %s -DCXX1Y2
Richard Smith661a9962011-10-15 01:18:56 +00003// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s
Richard Smith7fe62082011-10-15 05:09:34 +00004// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s
Richard Smith661a9962011-10-15 01:18:56 +00005// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s
6
Larisse Voufo539470e2013-06-15 20:17:46 +00007// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s -Wno-c++98-c++11-compat-pedantic -DCXX1Y2
Richard Smith24ce46c2013-05-17 03:11:25 +00008
Richard Smith661a9962011-10-15 01:18:56 +00009// -Wc++98-compat-pedantic warns on C++11 features which we accept without a
10// warning in C++98 mode.
11
12#line 32767 // ok
13#line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}}
14
15#define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}}
Richard Smith9f728cd2012-06-22 23:59:08 +000016VA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}}
Richard Smith7fe62082011-10-15 05:09:34 +000017
18; // expected-warning {{extra ';' outside of a function is incompatible with C++98}}
19
20enum Enum {
21 Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}}
22};
Richard Smithebaf0e62011-10-18 20:49:44 +000023
24template<typename T> struct InstantiationAfterSpecialization {};
25template<> struct InstantiationAfterSpecialization<int> {}; // expected-note {{here}}
26template struct InstantiationAfterSpecialization<int>; // expected-warning {{explicit instantiation of 'InstantiationAfterSpecialization<int>' that occurs after an explicit specialization is incompatible with C++98}}
27
28void *dlsym();
29void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
30void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
31
32struct ConvertToInt {
33 operator int();
34};
Larisse Voufo539470e2013-06-15 20:17:46 +000035int *ArraySizeConversion = new int[ConvertToInt()];
36#ifdef CXX1Y2
Larisse Voufo0bb51992013-06-18 01:27:47 +000037// expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}}
Larisse Voufo539470e2013-06-15 20:17:46 +000038#else
39// expected-warning@-4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}
40#endif
Richard Smith93245832011-10-20 18:35:58 +000041
42template<typename T> class ExternTemplate {};
43extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}}
Dmitri Gribenkoe3b136b2012-09-24 18:19:21 +000044
45long long ll1 = // expected-warning {{'long long' is incompatible with C++98}}
46 -42LL; // expected-warning {{'long long' is incompatible with C++98}}
47unsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}}
48 42ULL; // expected-warning {{'long long' is incompatible with C++98}}
49
Richard Smith2fcf0de2013-04-19 20:47:20 +000050int k = 0b1001;
51#ifdef CXX1Y
52// expected-warning@-2 {{binary integer literals are incompatible with C++ standards before C++1y}}
53#endif
Richard Smith39b0e262013-04-20 23:28:26 +000054
55void f(int n) { int a[n]; }
56#ifdef CXX1Y
57// expected-warning@-2 {{arrays of runtime bound are incompatible with C++ standards before C++1y}}
58#endif