public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jerry DeLisle <jvdelisle@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8947] Fortran: Set the length of an allocatable character Date: Tue, 13 Feb 2024 04:51:00 +0000 (GMT) [thread overview] Message-ID: <20240213045101.196A73858C52@sourceware.org> (raw) https://gcc.gnu.org/g:6caec7d9ec37e60e718a12934c85bac9c12757ac commit r14-8947-g6caec7d9ec37e60e718a12934c85bac9c12757ac Author: Steve Kargl <kargl@gcc.gnu.org> Date: Mon Feb 12 20:41:02 2024 -0800 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. Diff: --- gcc/fortran/trans-array.cc | 3 +++ gcc/testsuite/gfortran.dg/allocatable_length.f90 | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 1e0d698a9497..2181990aa04a 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -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); diff --git a/gcc/testsuite/gfortran.dg/allocatable_length.f90 b/gcc/testsuite/gfortran.dg/allocatable_length.f90 new file mode 100644 index 000000000000..e8b638fac880 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocatable_length.f90 @@ -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
reply other threads:[~2024-02-13 4:51 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240213045101.196A73858C52@sourceware.org \ --to=jvdelisle@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).