blob: 208ea4ce923864cebb254170c8b77d97cc5483a9 [file] [log] [blame]
Richard Smith2fcf0de2013-04-19 20:47:20 +00001// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat-pedantic -verify %s
2// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat -Werror %s
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
7// -Wc++98-compat-pedantic warns on C++11 features which we accept without a
8// warning in C++98 mode.
9
10#line 32767 // ok
11#line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}}
12
13#define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}}
Richard Smith9f728cd2012-06-22 23:59:08 +000014VA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}}
Richard Smith7fe62082011-10-15 05:09:34 +000015
16; // expected-warning {{extra ';' outside of a function is incompatible with C++98}}
17
18enum Enum {
19 Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}}
20};
Richard Smithebaf0e62011-10-18 20:49:44 +000021
22template<typename T> struct InstantiationAfterSpecialization {};
23template<> struct InstantiationAfterSpecialization<int> {}; // expected-note {{here}}
24template struct InstantiationAfterSpecialization<int>; // expected-warning {{explicit instantiation of 'InstantiationAfterSpecialization<int>' that occurs after an explicit specialization is incompatible with C++98}}
25
26void *dlsym();
27void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
28void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
29
30struct ConvertToInt {
31 operator int();
32};
33int *ArraySizeConversion = new int[ConvertToInt()]; // expected-warning {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}
Richard Smith93245832011-10-20 18:35:58 +000034
35template<typename T> class ExternTemplate {};
36extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}}
Dmitri Gribenkoe3b136b2012-09-24 18:19:21 +000037
38long long ll1 = // expected-warning {{'long long' is incompatible with C++98}}
39 -42LL; // expected-warning {{'long long' is incompatible with C++98}}
40unsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}}
41 42ULL; // expected-warning {{'long long' is incompatible with C++98}}
42
Richard Smith2fcf0de2013-04-19 20:47:20 +000043int k = 0b1001;
44#ifdef CXX1Y
45// expected-warning@-2 {{binary integer literals are incompatible with C++ standards before C++1y}}
46#endif
Richard Smith39b0e262013-04-20 23:28:26 +000047
48void f(int n) { int a[n]; }
49#ifdef CXX1Y
50// expected-warning@-2 {{arrays of runtime bound are incompatible with C++ standards before C++1y}}
51#endif