]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
expr: Handle BITINT_TYPE in count_type_elements [PR112881]
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 Dec 2023 08:47:16 +0000 (09:47 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 7 Dec 2023 08:47:16 +0000 (09:47 +0100)
The following testcaser ICEs during gimplification, because
count_type_elements doesn't handle BITINT_TYPE.  It should handle it like
other integral types.

2023-12-07  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/112881
* expr.cc (count_type_elements): Handle BITINT_TYPE like INTEGER_TYPE.

* gcc.dg/bitint-50.c: New test.

gcc/expr.cc
gcc/testsuite/gcc.dg/bitint-50.c [new file with mode: 0644]

index fea719028a162cd16be9a7dd4ed8fdafdd87439b..6da51f2aca296450848000ed7dc957fd28ebf55f 100644 (file)
@@ -7021,6 +7021,7 @@ count_type_elements (const_tree type, bool for_ctor_p)
     case REFERENCE_TYPE:
     case NULLPTR_TYPE:
     case OPAQUE_TYPE:
+    case BITINT_TYPE:
       return 1;
 
     case ERROR_MARK:
diff --git a/gcc/testsuite/gcc.dg/bitint-50.c b/gcc/testsuite/gcc.dg/bitint-50.c
new file mode 100644 (file)
index 0000000..ea7820e
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR middle-end/112881 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2 -std=c23" } */
+
+struct S { _BitInt(64) b; };
+
+struct S
+foo (_BitInt(64) p)
+{
+  return (struct S) { p };
+}
+
+#if __BITINT_MAXWIDTH__ >= 3924
+struct T { _BitInt(3924) b; };
+
+struct T
+bar (_BitInt(3924) p)
+{
+  return (struct T) { p };
+}
+#endif