]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Added BOZ support to UINT.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 4 Aug 2024 11:24:43 +0000 (13:24 +0200)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 4 Aug 2024 11:24:43 +0000 (13:24 +0200)
gcc/fortran/check.cc
gcc/fortran/expr.cc
gcc/fortran/simplify.cc
gcc/testsuite/gfortran.dg/unsigned_6.f90

index b07de09b6671064f0d7be61fedc479553bdafdce..360d06f2532c4a481d740e28e4e61708026c160c 100644 (file)
@@ -483,6 +483,9 @@ gfc_boz2uint (gfc_expr *x, int kind)
       mpz_and (x->value.integer, x->value.integer, gfc_unsigned_kinds[k].huge);
     }
 
+  x->ts.type = BT_UNSIGNED;
+  x->ts.kind = kind;
+
   /* Clear boz info.  */
   x->boz.rdx = 0;
   x->boz.len = 0;
index b47a84ae1a937be59f145ccfdbb74d3532d89a98..226e9da9a44cf0b980f4627f2b954e5eb1d9110a 100644 (file)
@@ -297,6 +297,7 @@ gfc_copy_expr (gfc_expr *p)
       switch (q->ts.type)
        {
        case BT_INTEGER:
+       case BT_UNSIGNED:
          mpz_init_set (q->value.integer, p->value.integer);
          break;
 
@@ -351,9 +352,6 @@ gfc_copy_expr (gfc_expr *p)
          strncpy (q->boz.str, p->boz.str, p->boz.len);
          break;
 
-       case BT_UNSIGNED:
-         gfc_internal_error ("Unsigned not yet implemented");
-
        case BT_PROCEDURE:
         case BT_VOID:
            /* Should never be reached.  */
index 0f4f8f506492f8d5db565fb14823242601310fb8..5bedab3f3f4ddbe4bc0053f2cc33117d1f3200a2 100644 (file)
@@ -3752,7 +3752,7 @@ gfc_simplify_uint (gfc_expr *e, gfc_expr *k)
   /* Convert BOZ to integer, and return without range checking.  */
   if (e->ts.type == BT_BOZ)
     {
-      if (!gfc_boz2int (e, kind))
+      if (!gfc_boz2uint (e, kind))
        return NULL;
       result = gfc_copy_expr (e);
       return result;
index 5caffeee7ab123e045ea4148a8a8b58c1fa4a976..677fdddec214b4bbc353e7220e6857ada6091509 100644 (file)
@@ -16,4 +16,6 @@ program main
   if (uint(r) /= 5u) error stop 5
   c = (6.2,-1.2)
   if (uint(c) /= 6u) error stop 6
+
+  if (uint(z'ff') /= 255u) error stop 7
 end program main