Fortran: Set the length of an allocatable character
PR fortran/113883 gcc/fortran/ChangeLog: * trans-array.cc (gfc_trans_deferred_array): Set length to zero, avoiding extraneous diagnostics. gcc/testsuite/ChangeLog: * gfortran.dg/allocatable_length.f90: New test.
This commit is contained in:
parent
b753ef8f0c
commit
6caec7d9ec
2 changed files with 12 additions and 0 deletions
|
@ -11531,6 +11531,9 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block)
|
|||
if (sym->ts.type == BT_CHARACTER
|
||||
&& !INTEGER_CST_P (sym->ts.u.cl->backend_decl))
|
||||
{
|
||||
if (sym->ts.deferred && !sym->ts.u.cl->length)
|
||||
gfc_add_modify (&init, sym->ts.u.cl->backend_decl,
|
||||
build_zero_cst (TREE_TYPE (sym->ts.u.cl->backend_decl)));
|
||||
gfc_conv_string_length (sym->ts.u.cl, NULL, &init);
|
||||
gfc_trans_vla_type_sizes (sym, &init);
|
||||
|
||||
|
|
9
gcc/testsuite/gfortran.dg/allocatable_length.f90
Normal file
9
gcc/testsuite/gfortran.dg/allocatable_length.f90
Normal file
|
@ -0,0 +1,9 @@
|
|||
! { dg-do compile }
|
||||
! { dg-options "-Werror -Wall" }
|
||||
module foo
|
||||
contains
|
||||
subroutine bar
|
||||
character(len=:), allocatable :: s(:)
|
||||
call bah(s)
|
||||
end subroutine bar
|
||||
end module foo
|
Loading…
Add table
Reference in a new issue