[clang] [clang] [SemaCXX] Implement CWG2627 Bit-fields and narrowing conversions (PR #78112)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu May 30 13:38:55 PDT 2024


================
@@ -1,11 +1,32 @@
-// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,cxx11
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx20
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx20,since-cxx23
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx20,since-cxx23
+// RUN: %clang_cc1 -std=c++98 %s -verify=expected
+// RUN: %clang_cc1 -std=c++11 %s -verify=expected,since-cxx11,cxx11
+// RUN: %clang_cc1 -std=c++14 %s -verify=expected,since-cxx11
+// RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx11
+// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11,since-cxx20
+// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11,since-cxx20,since-cxx23
+// RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx11,since-cxx20,since-cxx23
 
+namespace std {
+#if __cplusplus >= 202002L
+  struct strong_ordering {
+    int n;
+    constexpr operator int() const { return n; }
+    static const strong_ordering less, equal, greater;
+  };
+  constexpr strong_ordering strong_ordering::less{-1},
+      strong_ordering::equal{0}, strong_ordering::greater{1};
+#endif
+
+  typedef short int16_t;
+  typedef unsigned short uint16_t;
+  typedef int int32_t;
+  typedef unsigned uint32_t;
+  typedef long long int64_t;
+  typedef unsigned long long uint64_t;
+  __extension__ _Static_assert(sizeof(int16_t) == 2 && sizeof(int32_t) == 4 && sizeof(int64_t) == 8, "Some tests rely on these sizes");
----------------
Endilll wrote:

You should copy over and use "backport" of `static_assert` to C++98, like we often do in DR tests:
https://github.com/llvm/llvm-project/blob/0eb9e021b15f477b796a6aaed94c94887f19171c/clang/test/CXX/drs/cwg1xx.cpp#L8-L11

https://github.com/llvm/llvm-project/pull/78112


More information about the cfe-commits mailing list