@@ -4645,7 +4645,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym,
gfc_wrapped_block * block)
for (sym = proc_sym->tlink; sym != proc_sym; sym = sym->tlink)
{
- bool alloc_comp_or_fini = (sym->ts.type == BT_DERIVED)
+ bool alloc_comp_or_fini = (sym->ts.type == BT_DERIVED ||
sym->ts.type == BT_CLASS)
&& (sym->ts.u.derived->attr.alloc_comp
|| gfc_is_finalizable (sym->ts.u.derived,
NULL));
@@ -4859,8 +4859,11 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym,
gfc_wrapped_block * block)
case AS_ASSUMED_RANK:
case AS_DEFERRED:
- seen_trans_deferred_array = true;
- gfc_trans_deferred_array (sym, block);
+ if (sym->attr.pointer || sym->attr.allocatable ||
alloc_comp_or_fini)
+ {
+ seen_trans_deferred_array = true;
+ gfc_trans_deferred_array (sym, block);
+ }
if (sym->ts.type == BT_CHARACTER && sym->ts.deferred
&& sym->attr.result)
{
b/gcc/testsuite/gfortran.dg/PR93957.f90
new file mode 100644
@@ -0,0 +1,39 @@
+! { dg-do run }
+!
+! PR fortran/93957
+!
+
+function f_ice(this) result(that) bind(c)
+ use, intrinsic :: iso_c_binding, only: c_int
+
+ implicit none
+
+ integer(kind=c_int), intent(in) :: this(..)
+ integer(kind=c_int) :: that
+
+ that = size(this)
+ return
+end function f_ice
+
+program ice_p
+
+ use, intrinsic :: iso_c_binding, only: c_int
+
+ implicit none
+
+ interface
+ function f_ice(this) result(that) bind(c)
+ use, intrinsic :: iso_c_binding, only: c_int
+ integer(kind=c_int), intent(in) :: this(..)
+ integer(kind=c_int) :: that
+ end function f_ice
+ end interface
+
+ integer(kind=c_int), parameter :: n = 10
+
+ integer(kind=c_int) :: intp(n)
+
+ if(size(intp)/=n) stop 1
+ if(f_ice(intp)/=n) stop 2
+
+end program ice_p