brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · 73be677 Raw
100 lines · cpp
1// RUN: %clang_cc1 -std=c++23 -triple x86_64-linux -Wpre-c++23-compat -fsyntax-only -verify=cxx23 %s2// RUN: %clang_cc1 -std=c++20 -triple x86_64-linux -fsyntax-only -verify=cxx20 %s3// RUN: %clang_cc1 -std=c++23 -triple i686-linux -fsyntax-only -verify=cxx23-32 %s4// RUN: %clang_cc1 -x c -std=c11 -fsyntax-only -verify=c11 %s5 6#ifdef __cplusplus7 8typedef __SIZE_TYPE__ size_t;9// Assume ptrdiff_t is the signed integer type corresponding to size_t.10typedef __PTRDIFF_TYPE__ ssize_t;11 12template <typename, typename>13struct is_same { static constexpr bool value = false; };14 15template <typename T>16struct is_same<T, T> { static constexpr bool value = true; };17 18void SSizeT(void) {19  auto a1 = 1z;20  // cxx23-warning@-1 {{'size_t' suffix for literals is incompatible with C++ standards before C++23}}21  // cxx20-warning@-2 {{'size_t' suffix for literals is a C++23 extension}}22  static_assert(is_same<decltype(a1), ssize_t>::value);23 24  auto a2 = 1Z;25  // cxx23-warning@-1 {{'size_t' suffix for literals is incompatible with C++ standards before C++23}}26  // cxx20-warning@-2 {{'size_t' suffix for literals is a C++23 extension}}27  static_assert(is_same<decltype(a2), ssize_t>::value);28}29 30void SizeT(void) {31  auto a1 = 1uz;32  // cxx23-warning@-1 {{'size_t' suffix for literals is incompatible with C++ standards before C++23}}33  // cxx20-warning@-2 {{'size_t' suffix for literals is a C++23 extension}}34  static_assert(is_same<decltype(a1), size_t>::value);35 36  auto a2 = 1uZ;37  // cxx23-warning@-1 {{'size_t' suffix for literals is incompatible with C++ standards before C++23}}38  // cxx20-warning@-2 {{'size_t' suffix for literals is a C++23 extension}}39  static_assert(is_same<decltype(a2), size_t>::value);40 41  auto a3 = 1Uz;42  // cxx23-warning@-1 {{'size_t' suffix for literals is incompatible with C++ standards before C++23}}43  // cxx20-warning@-2 {{'size_t' suffix for literals is a C++23 extension}}44  static_assert(is_same<decltype(a3), size_t>::value);45 46  auto a4 = 1UZ;47  // cxx23-warning@-1 {{'size_t' suffix for literals is incompatible with C++ standards before C++23}}48  // cxx20-warning@-2 {{'size_t' suffix for literals is a C++23 extension}}49  static_assert(is_same<decltype(a4), size_t>::value);50 51  auto a5 = 1zu;52  // cxx23-warning@-1 {{'size_t' suffix for literals is incompatible with C++ standards before C++23}}53  // cxx20-warning@-2 {{'size_t' suffix for literals is a C++23 extension}}54  static_assert(is_same<decltype(a5), size_t>::value);55 56  auto a6 = 1Zu;57  // cxx23-warning@-1 {{'size_t' suffix for literals is incompatible with C++ standards before C++23}}58  // cxx20-warning@-2 {{'size_t' suffix for literals is a C++23 extension}}59  static_assert(is_same<decltype(a6), size_t>::value);60 61  auto a7 = 1zU;62  // cxx23-warning@-1 {{'size_t' suffix for literals is incompatible with C++ standards before C++23}}63  // cxx20-warning@-2 {{'size_t' suffix for literals is a C++23 extension}}64  static_assert(is_same<decltype(a7), size_t>::value);65 66  auto a8 = 1ZU;67  // cxx23-warning@-1 {{'size_t' suffix for literals is incompatible with C++ standards before C++23}}68  // cxx20-warning@-2 {{'size_t' suffix for literals is a C++23 extension}}69  static_assert(is_same<decltype(a8), size_t>::value);70}71 72void oor(void) {73#if __i386__74  (void)3'000'000'000z; // cxx23-32-error {{signed 'size_t' literal is out of range of possible signed 'size_t' values}}75  (void)3'000'000'000uz;76  (void)5'000'000'000uz; // cxx23-32-error {{'size_t' literal is out of range of possible 'size_t' values}}77 78  (void)0x80000000z;79  (void)0x80000000uz;80  (void)0x180000000uz; //cxx23-32-error {{'size_t' literal is out of range of possible 'size_t' values}}81#endif82}83 84#else85 86void f(void) {87  (void)1z;  // c11-error {{'size_t' suffix for literals is a C++23 feature}}88  (void)1Z;  // c11-error {{'size_t' suffix for literals is a C++23 feature}}89  (void)1uz; // c11-error {{'size_t' suffix for literals is a C++23 feature}}90  (void)1uZ; // c11-error {{'size_t' suffix for literals is a C++23 feature}}91  (void)1Uz; // c11-error {{'size_t' suffix for literals is a C++23 feature}}92  (void)1UZ; // c11-error {{'size_t' suffix for literals is a C++23 feature}}93  (void)1zu; // c11-error {{'size_t' suffix for literals is a C++23 feature}}94  (void)1Zu; // c11-error {{'size_t' suffix for literals is a C++23 feature}}95  (void)1zU; // c11-error {{'size_t' suffix for literals is a C++23 feature}}96  (void)1ZU; // c11-error {{'size_t' suffix for literals is a C++23 feature}}97}98 99#endif100