https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277
--- Comment #12 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to anlauf from comment #8)
> Enabling derived types does not work when they occur in an array constructor,
> and the code would ICE on empty constructors of derived type.
>
Looking at the code, I couldn't foresee where the ICE would happen, so I tried
it myself.
I see no ICE here.
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 04b5e30b96a..4fd3fb65a54 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -2941,10 +2941,6 @@ trans_array_constructor (gfc_ss * ss, locus * where)
from constructor only for meaningful shape. */
bool zero_sized = zero_sized_array_p (expr);
- /* FIXME: constant array constructors for DT have some issues... */
- if (expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS)
- zero_sized = false;
-
if (!zero_sized)
nelem = gfc_constant_array_constructor_p (c);
program test
implicit none
type :: t
integer :: c
end type t
integer :: m(0)
integer, allocatable :: n(:)
call i
call i(m)
call i(n)
allocate (n(0))
call i(n)
call i([integer::]) ! expect "optional argument present: T"
call i([1])
call j([t::])
contains
subroutine i(str)
integer, dimension(:), optional, intent(in) :: str
write(6,*) 'optional argument present:', present(str)
end subroutine i
subroutine j(str)
type(t), dimension(:), optional, intent(in) :: str
write(6,*) 'optional argument present:', present(str)
end subroutine j
end program