expr: Handle BITINT_TYPE in count_type_elements [PR112881]

Message ID ZXF5iPc/yqEcx8yS@tucnak
State Unresolved
Headers
Series expr: Handle BITINT_TYPE in count_type_elements [PR112881] |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek Dec. 7, 2023, 7:51 a.m. UTC
  Hi!

The following testcaser ICEs during gimplification, because
count_type_elements doesn't handle BITINT_TYPE.  It should handle it like
other integral types.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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.


	Jakub
  

Comments

Richard Biener Dec. 7, 2023, 7:57 a.m. UTC | #1
On Thu, 7 Dec 2023, Jakub Jelinek wrote:

> Hi!
> 
> The following testcaser ICEs during gimplification, because
> count_type_elements doesn't handle BITINT_TYPE.  It should handle it like
> other integral types.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

> 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.jj	2023-12-01 08:10:43.037319912 +0100
> +++ gcc/expr.cc	2023-12-06 17:36:15.437408307 +0100
> @@ -7021,6 +7021,7 @@ count_type_elements (const_tree type, bo
>      case REFERENCE_TYPE:
>      case NULLPTR_TYPE:
>      case OPAQUE_TYPE:
> +    case BITINT_TYPE:
>        return 1;
>  
>      case ERROR_MARK:
> --- gcc/testsuite/gcc.dg/bitint-50.c.jj	2023-12-06 17:37:15.502565091 +0100
> +++ gcc/testsuite/gcc.dg/bitint-50.c	2023-12-06 17:36:48.866939013 +0100
> @@ -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
> 
> 	Jakub
> 
>
  

Patch

--- gcc/expr.cc.jj	2023-12-01 08:10:43.037319912 +0100
+++ gcc/expr.cc	2023-12-06 17:36:15.437408307 +0100
@@ -7021,6 +7021,7 @@  count_type_elements (const_tree type, bo
     case REFERENCE_TYPE:
     case NULLPTR_TYPE:
     case OPAQUE_TYPE:
+    case BITINT_TYPE:
       return 1;
 
     case ERROR_MARK:
--- gcc/testsuite/gcc.dg/bitint-50.c.jj	2023-12-06 17:37:15.502565091 +0100
+++ gcc/testsuite/gcc.dg/bitint-50.c	2023-12-06 17:36:48.866939013 +0100
@@ -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