[Bug fortran/103418] random_number() does not accept pointer, intent(in) array argument
sgk at troutmask dot apl.washington.edu
gcc-bugzilla@gcc.gnu.org
Fri Nov 26 21:58:04 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103418
--- Comment #11 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Fri, Nov 26, 2021 at 08:13:05PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103418
>
> --- Comment #10 from anlauf at gcc dot gnu.org ---
> (In reply to Steve Kargl from comment #9)
> > "does not work for me" isn't too descriptive.
>
> Well, you fixed a related issue, but not the problem in comment#0.
>
> Try your patch on:
>
> module m
> contains
> subroutine s1 (a, b)
> real, pointer, intent(in) :: a, b(:)
> call random_number (a)
> call random_number (b)
> end subroutine s1
> end module
>
That's at least sufficient to fix your issue.
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 5a5aca10ebe..49bb9d350f0 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -1031,7 +1031,9 @@ variable_check (gfc_expr *e, int n, bool allow_proc)
break;
}
- if (!ref)
+ if (!ref
+ && !(pointer
+ && ((e->ref && e->ref->type == REF_ARRAY) || e->rank == 0)))
{
gfc_error ("%qs argument of %qs intrinsic at %L cannot be "
"INTENT(IN)", gfc_current_intrinsic_arg[n]->name,
@@ -1062,7 +1064,8 @@ variable_check (gfc_expr *e, int n, bool allow_proc)
return true;
gfc_error ("%qs argument of %qs intrinsic at %L must be a variable",
- gfc_current_intrinsic_arg[n]->name, gfc_current_intrinsic,
&e->where);
+ gfc_current_intrinsic_arg[n]->name, gfc_current_intrinsic,
+ &e->where);
return false;
}
More information about the Gcc-bugs
mailing list