_BitInt(5) unsigned d = (unsigned _BitInt(5)) 4;
_BitInt(32) e = (_BitInt(32)) 5;
_BitInt(32) unsigned f = (unsigned _BitInt(32)) 6;
+ constexpr int g = 43;
+ enum E { F = 44 };
+ _BitInt(g) h;
+ unsigned _BitInt(F) i;
static_assert (expr_has_type (a, signed _BitInt(42)), "");
static_assert (expr_has_type (a, _BitInt(42)), "");
static_assert (!expr_has_type (a, unsigned _BitInt(42)), "");
static_assert (expr_has_type (-1UWB, unsigned _BitInt(1)), "");
static_assert (expr_has_type (1uWB, unsigned _BitInt(1)), "");
static_assert (expr_has_type (2Uwb, unsigned _BitInt(2)), "");
+ static_assert (expr_has_type (h, signed _BitInt(43)), "");
+ static_assert (expr_has_type (i, unsigned _BitInt(44)), "");
static_assert (0wb == 0, "");
static_assert (-1wb == -1, "");
static_assert (0xffffffffwb == 4294967295wb, "");
check_round (testfltu_192 (340282356779733661637539395458142568448uwb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f);
check_round (testfltu_192 (6277101735386680763835789423207666416102355444464034512895uwb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f);
#endif
-#if 0 && __BITINT_MAXWIDTH__ >= 575
+#if __BITINT_MAXWIDTH__ >= 575
check_round (testflt_575 (10633823015541376812058405359715352575wb), 0xfffffep+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f);
check_round (testflt_575 (10633823015541376812058405359715352576wb), 0xfffffep+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f);
check_round (testflt_575 (10633823015541376812058405359715352577wb), 0xffffffp+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f);
--- /dev/null
+/* PR c/102989 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-std=c2x" } */
+
+#include <limits.h>
+
+#ifndef BITINT_MAXWIDTH
+#error BITINT_MAXWIDTH not defined
+#elif BITINT_MAXWIDTH < ULLONG_WIDTH
+#error BITINT_MAXWIDTH smaller than ULLONG_WIDTH
+#endif
+
+_BitInt(BITINT_MAXWIDTH) a;
+_BitInt(BITINT_MAXWIDTH + 1) b; /* { dg-error "'_BitInt' argument '\[0-9]+' is larger than 'BITINT_MAXWIDTH' '\[0-9]+'" } */
--- /dev/null
+/* PR c/102989 */
+/* { dg-do compile } */
+/* { dg-options "-std=c17" } */
+
+#include <limits.h>
+
+#ifdef BITINT_MAXWIDTH
+#error BITINT_MAXWIDTH defined in C11
+#endif
--- /dev/null
+/* PR c/102989 */
+/* Test that -funsigned-bitfields doesn't affect _BitInt bit-fields which are always signed. */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c2x -funsigned-bitfields" } */
+
+struct S { _BitInt(22) a : 7; signed _BitInt(22) b : 7; unsigned _BitInt(22) c : 7; } s;
+
+int
+main ()
+{
+ s.a = -64;
+ s.b = -64;
+ s.c = -64;
+ if (s.a != -64 || s.b != -64 || s.c != 64)
+ __builtin_abort ();
+}
--- /dev/null
+/* PR c/102989 */
+/* { dg-do compile { target { bitint && { float32 && int32 } } } } */
+/* { dg-options "-std=c2x -Wconversion -Wfloat-conversion" } */
+/* { dg-add-options float32 } */
+
+void
+foo (_Float32 x)
+{
+ _BitInt(57) a = 1.5F32; /* { dg-warning "conversion from '_Float32' to '_BitInt\\\(57\\\)' changes value from '1.5e\\\+0f32' to '1'" } */
+ _BitInt(27) b = 76117358uwb; /* { dg-warning "signed conversion from 'unsigned _BitInt\\\(27\\\)' to '_BitInt\\\(27\\\)' changes value from '76117358' to '-58100370'" } */
+ unsigned _BitInt(27) c = -15wb; /* { dg-warning "unsigned conversion from '_BitInt\\\(5\\\)' to 'unsigned _BitInt\\\(27\\\)' changes value from '-15' to '134217713'" } */
+ _BitInt(27) d = -390288573wb; /* { dg-warning "overflow in conversion from '_BitInt\\\(30\\\)' to '_BitInt\\\(27\\\)' changes value from '-390288573' to '12364611'" } */
+ unsigned _BitInt(27) e = 309641337uwb; /* { dg-warning "conversion from 'unsigned _BitInt\\\(29\\\)' to 'unsigned _BitInt\\\(27\\\)' changes value from '309641337' to '41205881'" } */
+ _BitInt(27) f = 76117358U; /* { dg-warning "signed conversion from 'unsigned int' to '_BitInt\\\(27\\\)' changes value from '76117358' to '-58100370'" } */
+ unsigned _BitInt(27) g = -15; /* { dg-warning "unsigned conversion from 'int' to 'unsigned _BitInt\\\(27\\\)' changes value from '-15' to '134217713'" } */
+ _BitInt(27) h = -390288573; /* { dg-warning "overflow in conversion from 'int' to '_BitInt\\\(27\\\)' changes value from '-390288573' to '12364611'" } */
+ unsigned _BitInt(27) i = 309641337U; /* { dg-warning "conversion from 'unsigned int' to 'unsigned _BitInt\\\(27\\\)' changes value from '309641337' to '41205881'" } */
+ int j = 2936216298uwb; /* { dg-warning "signed conversion from 'unsigned _BitInt\\\(32\\\)' to 'int' changes value from '2936216298' to '-1358750998'" } */
+ unsigned int k = -15wb; /* { dg-warning "unsigned conversion from '_BitInt\\\(5\\\)' to 'unsigned int' changes value from '-15' to '4294967281'" } */
+ int l = -8087431137529383656wb; /* { dg-warning "overflow in conversion from '_BitInt\\\(64\\\)' to 'int' changes value from '-8087431137529383656' to '-1105152744'" } */
+ unsigned int m = 1664073919553255778uwb; /* { dg-warning "conversion from 'unsigned _BitInt\\\(61\\\)' to 'unsigned int' changes value from '1664073919553255778' to '3338058082'" } */
+#if __BITINT_MAXWIDTH__ >= 575
+ _Float32 n = 51441631083309184313435496923626431699697406185384986811300218556561965470218425783308778801748592322915101142266821623326688106425864884688172114173397118407357447763009120wb; /* { dg-warning "conversion from '_BitInt\\\(575\\\)' to '_Float32' changes value from '0x353eab28b46b03ea99b84f9736cd8dbe5e986915a0383c3cb381c0da41e31b3621c75fd53262bfcb1b0e6251dbf00f3988784e29b08b65640c263e4d0959832a20e2ff5245be1e60' to '\\\+Inff32'" "" { target bitint575 } } */
+#endif
+ _BitInt(57) o = x; /* { dg-warning "conversion from '_Float32' to '_BitInt\\\(57\\\)' may change value" } */
+ unsigned _BitInt(15) p = 32767uwb;
+ unsigned _BitInt(15) q = (_BitInt(42)) p;
+ _BitInt(17) r = 0;
+ _BitInt(17) s = ((_BitInt(42)) r) & 32767wb;
+#if __BITINT_MAXWIDTH__ >= 575
+ _BitInt(575) t = 0;
+ _Float32 u = t; /* { dg-warning "conversion from '_BitInt\\\(575\\\)' to '_Float32' may change value" "" { target bitint575 } } */
+#endif
+ _BitInt(42) v = 0;
+ unsigned _BitInt(17) w = v; /* { dg-warning "conversion from '_BitInt\\\(42\\\)' to 'unsigned _BitInt\\\(17\\\)' may change value" } */
+ _BitInt(17) y = v; /* { dg-warning "conversion from '_BitInt\\\(42\\\)' to '_BitInt\\\(17\\\)' may change value" } */
+}
--- /dev/null
+/* PR c/102989 */
+/* { dg-do compile { target { bitint } } } */
+/* { dg-options "-std=c2x -Wint-in-bool-context -Waddress -Wpointer-to-int-cast -Wint-to-pointer-cast -Wint-conversion -Wshift-negative-value -Wshift-count-overflow -Wdiv-by-zero" } */
+
+extern char *ax[];
+
+void bar (int);
+
+void
+foo (_BitInt(61) x, long long *y)
+{
+ if (x << 15) /* { dg-warning "'<<' in boolean context, did you mean '<'" } */
+ ;
+ bar ((_BitInt(sizeof (void *) * __CHAR_BIT__)) (ax + 0) == 0);
+ bar ((unsigned _BitInt(sizeof (void *) * __CHAR_BIT__)) (ax + 1) == 0);
+ char *z = __builtin_assume_aligned (y, 32wb, 8wb);
+ *z = 42;
+ _BitInt(sizeof (void *) * __CHAR_BIT__ + 1) a = (_BitInt(sizeof (void *) * __CHAR_BIT__ + 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */
+ unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ + 1) b = (unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ + 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */
+ _BitInt(sizeof (void *) * __CHAR_BIT__ - 1) c = (_BitInt(sizeof (void *) * __CHAR_BIT__ - 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */
+ unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ - 1) d = (unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ - 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */
+ void *e = (void *) a; /* { dg-warning "cast to pointer from integer of different size" } */
+ void *f = (void *) b; /* { dg-warning "cast to pointer from integer of different size" } */
+ void *g = (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */
+ void *h = (void *) d; /* { dg-warning "cast to pointer from integer of different size" } */
+ a = y; /* { dg-warning "assignment to '_BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */
+ b = y; /* { dg-warning "assignment to 'unsigned _BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */
+ c = y; /* { dg-warning "assignment to '_BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */
+ d = y; /* { dg-warning "assignment to 'unsigned _BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */
+ e = a; /* { dg-warning "assignment to 'void \\\*' from '_BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */
+ f = b; /* { dg-warning "assignment to 'void \\\*' from 'unsigned _BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */
+ g = c; /* { dg-warning "assignment to 'void \\\*' from '_BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */
+ h = d; /* { dg-warning "assignment to 'void \\\*' from 'unsigned _BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */
+ _BitInt(61) i = (1wb - 1152921504606846975wb) << 1; /* { dg-warning "left shift of negative value" } */
+ /* { dg-warning "result of '-1152921504606846974 << 1' requires 62 bits to represent, but '_BitInt\\\(61\\\)' only has 61 bits" "" { target *-*-* } .-1 } */
+ _BitInt(61) j = i << (60 + 1); /* { dg-warning "left shift count >= width of type" } */
+ _BitInt(61) k = i >> (60 + 1); /* { dg-warning "right shift count >= width of type" } */
+ _BitInt(61) l = i / (51wb - 51wb); /* { dg-warning "division by zero" } */
+}
--- /dev/null
+/* PR c/102989 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-std=c2x" } */
+
+void
+foo (void)
+{
+ _Sat _BitInt (42) a; /* { dg-error "both '_Sat' and '_BitInt' in declaration specifiers" } */
+ _BitInt (42) _Sat b; /* { dg-error "both '_Sat' and '_BitInt' in declaration specifiers" } */
+}