[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / cxx98-compat-pedantic.cpp
blob3a4776591814d557bf99e0d0e860119865d353ae
1 // 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
3 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s
4 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s
5 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s -DCXX98
7 // RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s -Wno-pre-c++14-compat-pedantic -DCXX1Y2
9 // -Wc++98-compat-pedantic warns on C++11 features which we accept without a
10 // warning in C++98 mode.
12 #line 32767 // ok
13 #line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}}
15 #define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}}
16 VA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}}
18 ; // expected-warning {{extra ';' outside of a function is incompatible with C++98}}
20 enum Enum {
21 Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}}
24 void *dlsym();
25 void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
26 void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
28 struct ConvertToInt {
29 operator int();
31 int *ArraySizeConversion = new int[ConvertToInt()];
32 #ifdef CXX1Y2
33 // expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}}
34 #else
35 // expected-warning@-4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}
36 #endif
38 template<typename T> class ExternTemplate {};
39 extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}}
41 long long ll1 = // expected-warning {{'long long' is incompatible with C++98}}
42 -42LL; // expected-warning {{'long long' is incompatible with C++98}}
43 unsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}}
44 42ULL; // expected-warning {{'long long' is incompatible with C++98}}
46 int k = 0b1001;
47 #ifdef CXX1Y
48 // expected-warning@-2 {{binary integer literals are incompatible with C++ standards before C++14}}
49 #endif
51 namespace CopyCtorIssues {
52 struct Private {
53 Private();
54 private:
55 Private(const Private&); // expected-note {{declared private here}}
57 struct NoViable {
58 NoViable(); // expected-note {{not viable}}
59 NoViable(NoViable&); // expected-note {{not viable}}
61 struct Ambiguous {
62 Ambiguous();
63 Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
64 Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
66 struct Deleted {
67 Private p; // expected-note {{implicitly deleted}}
70 const Private &a = Private(); // expected-warning {{copying variable of type 'Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
71 const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
72 #if !CXX98
73 const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}}
74 #endif
75 const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}