When looking for an array reference allow NULL references. If
no array reference is found dim_rank_check should return false.
2020-07-13 Steven G. Kargl <kargl@gcc.gnu.org>
gcc/fortran/
PR fortran/95981
* check.c (dim_rank_check): Allow NULL references in call to
gfc_find_array_ref and return false if no reference is found.
2020-07-13 Mark Eggleston <markeggleston@gcc.gnu.org>
gcc/testsuite/
PR fortran/95981
* gfortran.dg/pr95981.f90: New test.
if (array->expr_type == EXPR_VARIABLE)
{
- ar = gfc_find_array_ref (array);
+ ar = gfc_find_array_ref (array, true);
+ if (!ar)
+ return false;
if (ar->as->type == AS_ASSUMED_SIZE
&& !allow_assumed
&& ar->type != AR_ELEMENT
--- /dev/null
+! { dg-do compile }
+
+program p
+ type t
+ end type
+ class(t) :: x(:) ! { dg-error "must be dummy, allocatable or pointer" }
+ type(t) :: y(size(x,1)) ! { dg-error "must be constant of INTEGER type" }
+end
+