aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2024-09-28 22:29:56 +0200
committerThomas Koenig <tkoenig@gcc.gnu.org>2024-09-28 22:29:56 +0200
commit786773d4c12fd78e94f58193ff303cba19ca1b19 (patch)
tree9292ff99082d665b9c07e8220fa7f16b9aa96030 /gcc/fortran
parent1c928004cf0bc2131b6199905d11133d23a7cef2 (diff)
downloadgcc-786773d4c12fd78e94f58193ff303cba19ca1b19.zip
gcc-786773d4c12fd78e94f58193ff303cba19ca1b19.tar.gz
gcc-786773d4c12fd78e94f58193ff303cba19ca1b19.tar.bz2
Implement FINDLOC for UNSIGNED.
gcc/fortran/ChangeLog: * check.cc (intrinsic_type_check): Handle unsigned. (gfc_check_findloc): Likewise. * gfortran.texi: Include FINDLOC in unsigned documentation. * iresolve.cc (gfc_resolve_findloc): Use INTEGER version for UNSIGNED. gcc/testsuite/ChangeLog: * gfortran.dg/unsigned_33.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/check.cc5
-rw-r--r--gcc/fortran/gfortran.texi3
-rw-r--r--gcc/fortran/iresolve.cc9
3 files changed, 14 insertions, 3 deletions
diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc
index 1da269f..dd79a49 100644
--- a/gcc/fortran/check.cc
+++ b/gcc/fortran/check.cc
@@ -643,7 +643,7 @@ intrinsic_type_check (gfc_expr *e, int n)
{
if (e->ts.type != BT_INTEGER && e->ts.type != BT_REAL
&& e->ts.type != BT_COMPLEX && e->ts.type != BT_CHARACTER
- && e->ts.type != BT_LOGICAL)
+ && e->ts.type != BT_LOGICAL && e->ts.type != BT_UNSIGNED)
{
gfc_error ("%qs argument of %qs intrinsic at %L must be of intrinsic type",
gfc_current_intrinsic_arg[n]->name,
@@ -4267,6 +4267,9 @@ gfc_check_findloc (gfc_actual_arglist *ap)
if ((a1 && !v1) || (!a1 && v1))
goto incompat;
+ if (flag_unsigned && gfc_invalid_unsigned_ops (a,v))
+ goto incompat;
+
/* Check the kind of the characters argument match. */
if (a1 && v1 && a->ts.kind != v->ts.kind)
goto incompat;
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index b42d009..7aa1642 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -2791,7 +2791,8 @@ As of now, the following intrinsics take unsigned arguments:
@item @code{SUM}, @code{PRODUCT}, @code{MATMUL} and @code{DOT_PRODUCT}
@item @code{IANY}, @code{IALL} and @code{IPARITY}
@item @code{RANDOM_NUMBER}
-@item @code{CSHIFT} and @code{EOSHIFT}.
+@item @code{CSHIFT} and @code{EOSHIFT}
+@item @code{FINDLOC}.
@end itemize
This list will grow in the near future.
@c ---------------------------------------------------------------------
diff --git a/gcc/fortran/iresolve.cc b/gcc/fortran/iresolve.cc
index 5a1e0a6..9fb2212 100644
--- a/gcc/fortran/iresolve.cc
+++ b/gcc/fortran/iresolve.cc
@@ -1819,6 +1819,7 @@ gfc_resolve_findloc (gfc_expr *f, gfc_expr *array, gfc_expr *value,
int i, j, idim;
int fkind;
int d_num;
+ bt type;
/* See at the end of the function for why this is necessary. */
@@ -1897,9 +1898,15 @@ gfc_resolve_findloc (gfc_expr *f, gfc_expr *array, gfc_expr *value,
gfc_convert_type_warn (back, &ts, 2, 0);
}
+ /* Use the INTEGER library function for UNSIGNED. */
+ if (array->ts.type != BT_UNSIGNED)
+ type = array->ts.type;
+ else
+ type = BT_INTEGER;
+
f->value.function.name
= gfc_get_string (PREFIX ("%s%d_%c%d"), name, d_num,
- gfc_type_letter (array->ts.type, true),
+ gfc_type_letter (type, true),
gfc_type_abi_kind (&array->ts));
/* We only have a single library function, so we need to convert