blob: 18fd1520ec4e32ad6539c8f6d8efd64268516f45 [file] [log] [blame]
Richard Smith661a9962011-10-15 01:18:56 +00001// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s
Richard Smith7fe62082011-10-15 05:09:34 +00002// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s
Richard Smith661a9962011-10-15 01:18:56 +00003// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s
4
5// -Wc++98-compat-pedantic warns on C++11 features which we accept without a
6// warning in C++98 mode.
7
8#line 32767 // ok
9#line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}}
10
11#define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}}
Richard Smith9f728cd2012-06-22 23:59:08 +000012VA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}}
Richard Smith7fe62082011-10-15 05:09:34 +000013
14; // expected-warning {{extra ';' outside of a function is incompatible with C++98}}
15
16enum Enum {
17 Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}}
18};
Richard Smithebaf0e62011-10-18 20:49:44 +000019
20template<typename T> struct InstantiationAfterSpecialization {};
21template<> struct InstantiationAfterSpecialization<int> {}; // expected-note {{here}}
22template struct InstantiationAfterSpecialization<int>; // expected-warning {{explicit instantiation of 'InstantiationAfterSpecialization<int>' that occurs after an explicit specialization is incompatible with C++98}}
23
24void *dlsym();
25void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
26void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
27
28struct ConvertToInt {
29 operator int();
30};
31int *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 +000032
33template<typename T> class ExternTemplate {};
34extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}}
Dmitri Gribenkoe3b136b2012-09-24 18:19:21 +000035
36long long ll1 = // expected-warning {{'long long' is incompatible with C++98}}
37 -42LL; // expected-warning {{'long long' is incompatible with C++98}}
38unsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}}
39 42ULL; // expected-warning {{'long long' is incompatible with C++98}}
40