Hi Thomas,

one small nit:

diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc
index dd79a49a0c9..afab66a901f 100644
--- a/gcc/fortran/check.cc
+++ b/gcc/fortran/check.cc
@@ -637,6 +637,38 @@ int_or_real_or_char_check_f2003 (gfc_expr *e, int n)
   return true;
 }

+/* Check that an expression is integer or real or unsigned; allow character for
+   F2003 or later.  */
+
+static bool
+int_or_real_or_char_or_unsigned_check_f2003 (gfc_expr *e, int n)
+{
+  if (e->ts.type != BT_INTEGER && e->ts.type != BT_REAL
+      && e->ts.type != BT_UNSIGNED)
+    {
+      if (e->ts.type == BT_CHARACTER)
+       return gfc_notify_std (GFC_STD_F2003, "Fortran 2003: Character for "
+                              "%qs argument of %qs intrinsic at %L",
+                              gfc_current_intrinsic_arg[n]->name,
+                              gfc_current_intrinsic, &e->where);
+      else
+       {
+         if (gfc_option.allow_std & GFC_STD_F2003)
+           gfc_error ("%qs argument of %qs intrinsic at %L must be INTEGER "
+                      "or REAL or CHARACTER",

I had expected UNSIGNED in this enumeration, too.

+                      gfc_current_intrinsic_arg[n]->name,
+                      gfc_current_intrinsic, &e->where);
+         else
+           gfc_error ("%qs argument of %qs intrinsic at %L must be INTEGER "
+                      "or REAL", gfc_current_intrinsic_arg[n]->name,

Same.

+                      gfc_current_intrinsic, &e->where);
+       }
+      return false;
+    }
+
+  return true;
+}
+
 /* Check that an expression is an intrinsic type.  */
 static bool
 intrinsic_type_check (gfc_expr *e, int n)


Ok for mainline with me.

Thanks for the patch,
        Andre

On Sun, 29 Sep 2024 16:22:57 +0200
Thomas Koenig <tkoe...@netcologne.de> wrote:

> Hello world,
>
> here's the implementation for MAXVAL and MINVAL for UNSIGNED.
>
> I found https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116886
> while working on the test case (something to be fixed later).
>
> (@Mikael: This actually touches trans-intrinsic.cc, but I don't
> think there will be collisions with what you're working on, it
> is only the part where the minimum/maximum is set).
>
> Regression-tested. OK for trunk?
>
> Best regards
>
>       Thomas
>
> gcc/fortran/ChangeLog:
>
>       * check.cc (int_or_real_or_char_or_unsigned_check_f2003): New
> function. (gfc_check_minval_maxval): Use it.
>       * trans-intrinsic.cc (gfc_conv_intrinsic_minmaxval): Handle
>       initial values for UNSIGNED.
>       * gfortran.texi: Document MINVAL and MAXVAL for unsigned.
>
> libgfortran/ChangeLog:
>
>       * Makefile.am: Add minval and maxval files.
>       * Makefile.in: Regenerated.
>       * gfortran.map: Add new functions.
>       * generated/maxval_m1.c: New file.
>       * generated/maxval_m16.c: New file.
>       * generated/maxval_m2.c: New file.
>       * generated/maxval_m4.c: New file.
>       * generated/maxval_m8.c: New file.
>       * generated/minval_m1.c: New file.
>       * generated/minval_m16.c: New file.
>       * generated/minval_m2.c: New file.
>       * generated/minval_m4.c: New file.
>       * generated/minval_m8.c: New file.
>
> gcc/testsuite/ChangeLog:
>
>       * gfortran.dg/unsigned_34.f90: New test.


--
Andre Vehreschild * Email: vehre ad gmx dot de

Reply via email to