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.
(cherry picked from commit
8fa9e73e6db0ff05447f5547df925fdcb4733d05)
+2021-09-22 Sandra Loosemore <sandra@codesourcery.com>
+
+ Backported from master:
+ 2021-09-19 Sandra Loosemore <sandra@codesourcery.com>
+
+ * trans-stmt.c (trans_associate_var): Check that result of
+ GFC_DECL_SAVED_DESCRIPTOR is not null before using it.
+
2021-09-22 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
/* Go straight to the class data. */
if (sym2->attr.dummy && !sym2->attr.optional)
{
- class_decl = DECL_LANG_SPECIFIC (sym2->backend_decl) ?
- GFC_DECL_SAVED_DESCRIPTOR (sym2->backend_decl) :
- sym2->backend_decl;
+ class_decl = sym2->backend_decl;
+ if (DECL_LANG_SPECIFIC (class_decl)
+ && GFC_DECL_SAVED_DESCRIPTOR (class_decl))
+ class_decl = GFC_DECL_SAVED_DESCRIPTOR (class_decl);
if (POINTER_TYPE_P (TREE_TYPE (class_decl)))
class_decl = build_fold_indirect_ref_loc (input_location,
class_decl);
+2021-09-22 Sandra Loosemore <sandra@codesourcery.com>
+
+ Backported from master:
+ 2021-09-19 Sandra Loosemore <sandra@codesourcery.com>
+
+ * 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.
+
2021-09-22 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
contains
subroutine g(x)
real :: x(..)
- call h(x)
+ select rank (x)
+ rank (1)
+ call h(x)
+ end select
end
subroutine h(x)
real :: x(*)
subroutine test_array (a)
use iso_c_binding, only: c_size_t
class(*), dimension(..), target :: a
- call test_lib (a, int (sizeof (a), kind=c_size_t))
+ select rank (a)
+ rank (1)
+ call test_lib (a, int (sizeof (a), kind=c_size_t))
+ end select
end subroutine
end module
subroutine test_array (a)
use iso_c_binding, only: c_size_t
class(*), dimension(..), target :: a
- call test_lib (a, int (sizeof (a), kind=c_size_t))
+ select rank (a)
+ rank (1)
+ call test_lib (a, int (sizeof (a), kind=c_size_t))
+ end select
end subroutine
end module