[clang] [clang] Implement CWG2627 Bit-fields and narrowing conversions (PR #78112)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 31 05:47:02 PDT 2024
================
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-linux-pc -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-windows-pc -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i386-linux-pc -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i386-windows-pc -fsyntax-only -verify -std=c++11 %s
+
+#if __BITINT_MAXWIDTH__ >= 35
+struct {
+ _BitInt(35) i : 33;
+} x;
+struct {
+ _BitInt(35) i : 34;
+} y;
+_BitInt(33) xx{ x.i };
+_BitInt(33) yy{ y.i };
+// expected-error at -1 {{non-constant-expression cannot be narrowed from type '_BitInt(35)' to '_BitInt(33)' in initializer list}}
+// FIXME-expected-note at -2 {{insert an explicit cast to silence this issue}}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 3
----------------
AaronBallman wrote:
Same here
https://github.com/llvm/llvm-project/pull/78112
More information about the cfe-commits
mailing list