https://gcc.gnu.org/g:94f538f91784bfb1c23d77271e7cc45366639eb9

commit r17-6676-g94f538f91784bfb1c23d77271e7cc45366639eb9
Author: Jakub Jelinek <[email protected]>
Date:   Wed Nov 25 09:56:30 2026 +0100

    tree: Fix _BitInt enum handling in signed_or_unsigned_type_for [PR128865]
    
    This is a spot I've apparently missed when adding support for C2Y enums
    with underlying _BitInt type.  Even for those we want for
    {,un}signed_type_for to return {,un}signed_type_for of the underlying type
    (i.e. some _BitInt) rather than build_nonstandard_integer_type.
    
    2026-11-25  Jakub Jelinek  <[email protected]>
    
            PR middle-end/128865
            * tree.cc (signed_or_unsigned_type_for): Test BITINT_TYPE_P (type)
            rather than TREE_CODE (type) == BITINT_TYPE whether to call
            build_bitint_type.
    
            * gcc.dg/bitint-151.c: New test.
    
    Reviewed-by: Richard Biener <[email protected]>

Diff:
---
 gcc/testsuite/gcc.dg/bitint-151.c | 11 +++++++++++
 gcc/tree.cc                       |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/bitint-151.c 
b/gcc/testsuite/gcc.dg/bitint-151.c
new file mode 100644
index 000000000000..f8d6069be3b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-151.c
@@ -0,0 +1,11 @@
+/* PR middle-end/128865 */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -O2" } */
+
+enum E : signed _BitInt(256) { E90 = 90 };
+
+int
+foo (enum E x)
+{
+  return x > E90 || x < 0;
+}
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 376e5f715e8b..dd0d61dd73a8 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -11715,7 +11715,7 @@ signed_or_unsigned_type_for (int unsignedp, tree type)
   else
     return NULL_TREE;
 
-  if (TREE_CODE (type) == BITINT_TYPE)
+  if (BITINT_TYPE_P (type))
     return build_bitint_type (bits, unsignedp);
   return build_nonstandard_integer_type (bits, unsignedp);
 }

Reply via email to