Fortran: Fix testcases that violate C838, + revealed ICE
authorSandra Loosemore <sandra@codesourcery.com>
Mon, 20 Sep 2021 00:23:58 +0000 (17:23 -0700)
committerSandra Loosemore <sandra@codesourcery.com>
Thu, 23 Sep 2021 00:09:29 +0000 (17:09 -0700)
commit8fa9e73e6db0ff05447f5547df925fdcb4733d05
treeb1d036675945e2d88c1498ea51db041f2d847f66
parent83aac698835edcdb3e6d96b856bef1c5f92e5e24
Fortran: Fix testcases that violate C838, + revealed ICE

The three test cases fixed in this patch violated F2018 C838, which
only allows passing an assumed-rank argument to an assumed-rank dummy.
Wrapping the call in "select rank" revealed a null pointer dereference
which is fixed by guarding the use of the result of
GFC_DECL_SAVED_DESCRIPTOR similar to what is already done elsewhere.

2021-09-19  Sandra Loosemore  <sandra@codesourcery.com>

gcc/fortran/
* trans-stmt.c (trans_associate_var): Check that result of
GFC_DECL_SAVED_DESCRIPTOR is not null before using it.

gcc/testsuite/
* gfortran.dg/assumed_rank_18.f90 (g): Wrap call to h in
select rank.
* gfortran.dg/assumed_type_10.f90 (test_array): Likewise for
call to test_lib.
* gfortran.dg/assumed_type_11.f90 (test_array): Likewise.
gcc/fortran/trans-stmt.c
gcc/testsuite/gfortran.dg/assumed_rank_18.f90
gcc/testsuite/gfortran.dg/assumed_type_10.f90
gcc/testsuite/gfortran.dg/assumed_type_11.f90