Hi Thomas,

the patch is basically fine.

I am wondering if we should create a new helper function that is
the opposite of type_check ("type_cannot_be"), so that we avoid
redundant code at the source level.  It may not be worth it yet,
so your choice.

Furthermore, if you planned to list intrinsics alphabetically,

diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 429d8461f8f..00276b5b45d 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi

this part needs corrected (in my counting, M comes before S):

@@ -2780,6 +2781,7 @@ The following intrinsics take unsigned arguments:
 @item @code{BLE}, @pxref{BLE}
 @item @code{BLT}, @pxref{BLT}
 @item @code{CSHIFT}, @pxref{CSHIFT}
+@item @code{CMPLX}, @pxref{CMPLX}
 @item @code{DIGITS}, @pxref{DIGITS}
 @item @code{DOT_PRODUCT}, @pxref{DOT_PRODUCT}
 @item @code{DSHIFTL}, @pxref{DSHIFTL}

Not being a native speaker, I stumbled over this:

diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 9d0b752670b..d11d37761d9 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi

@@ -3637,9 +3638,9 @@ Elemental function
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
-or @code{COMPLEX}.
+@code{COMPLEX} or @code{UNSIGNED}.
 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
-@code{COMPLEX}.)  May be @code{INTEGER} or @code{REAL}.
+@code{COMPLEX}.)  May be @code{INTEGER}, @code{REAL} or @code{UNSIGNED}.
                   ^^^ Shouldn't one add "The type" before "may be"?

 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
 expression indicating the kind parameter of the result.
 @end multitable


OK for mainline after considering the above comments.

Thanks for the patch!

Harald

Am 09.11.24 um 17:53 schrieb Thomas Koenig:
Hello world,

the attached patch rejects UNSIGNED arguments for the COMPLEX
function, which is an extension.  It also documents CMPLX,
INT and REAL as taking UNSIGNED arguments.

Regression-tested. OK for trunk?

Best regards

     Thomas

gcc/fortran/ChangeLog:

     * check.cc (gfc_check_complex): Reject UNSIGNED.
     * gfortran.texi: Update example program.  Note that
     CMPLX, INT and REAL also take unsigned arguments.
     * intrinsic.texi (CMPLX): Document UNSIGNED.
     (INT): Likewise.
     (REAL): Likewise.

gcc/testsuite/ChangeLog:

     * gfortran.dg/unsigned_41.f90: New test.

Reply via email to