public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] Fortran: Fix character(len=cst) dummies with bind(C) [PR102885] Date: Tue, 26 Oct 2021 14:11:17 +0000 (GMT) [thread overview] Message-ID: <20211026141117.0A08B3858C3A@sourceware.org> (raw) https://gcc.gnu.org/g:c1c7a10911ba16d06894f4a563a1f81bf1c03e0e commit c1c7a10911ba16d06894f4a563a1f81bf1c03e0e Author: Tobias Burnus <tobias@codesourcery.com> Date: Tue Oct 26 16:04:52 2021 +0200 Fortran: Fix character(len=cst) dummies with bind(C) [PR102885] PR fortran/102885 gcc/fortran/ChangeLog: * trans-decl.c (gfc_conv_cfi_to_gfc): Properly handle nonconstant character lenghts. gcc/testsuite/ChangeLog: * gfortran.dg/lto/bind-c-char_0.f90: New test. (cherry picked from commit a31a3d0421f0cf1f7eefacfec8cbf37e7f91600d) Diff: --- gcc/fortran/ChangeLog.omp | 9 +++++ gcc/fortran/trans-decl.c | 7 ++++ gcc/testsuite/ChangeLog.omp | 8 ++++ gcc/testsuite/gfortran.dg/lto/bind-c-char_0.f90 | 49 +++++++++++++++++++++++++ 4 files changed, 73 insertions(+) diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index 4ca778c2135..c1f975072c0 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,12 @@ +2021-10-26 Tobias Burnus <tobias@codesourcery.com> + + Backport from master: + 2021-10-26 Tobias Burnus <tobias@codesourcery.com> + + PR fortran/102885 + * trans-decl.c (gfc_conv_cfi_to_gfc): Properly handle nonconstant + character lenghts. + 2021-10-21 Tobias Burnus <tobias@codesourcery.com> Backport from master: diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 57d044d4923..5a9754007b5 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -6835,6 +6835,13 @@ gfc_conv_cfi_to_gfc (stmtblock_t *init, stmtblock_t *finally, gfc_add_modify (&block, sym->ts.u.cl->backend_decl, tmp); } + if (sym->ts.type == BT_CHARACTER + && !INTEGER_CST_P (sym->ts.u.cl->backend_decl)) + { + gfc_conv_string_length (sym->ts.u.cl, NULL, init); + gfc_trans_vla_type_sizes (sym, init); + } + /* gfc->data = cfi->base_addr - or for scalars: gfc = cfi->base_addr. assumed-size/explicit-size arrays end up here for character(len=*) only. */ diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 735c4105008..159227b39f7 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,11 @@ +2021-10-26 Tobias Burnus <tobias@codesourcery.com> + + Backport from master: + 2021-10-26 Tobias Burnus <tobias@codesourcery.com> + + PR fortran/102885 + * gfortran.dg/lto/bind-c-char_0.f90: New test. + 2021-10-21 Tobias Burnus <tobias@codesourcery.com> Backport from master: diff --git a/gcc/testsuite/gfortran.dg/lto/bind-c-char_0.f90 b/gcc/testsuite/gfortran.dg/lto/bind-c-char_0.f90 new file mode 100644 index 00000000000..48b495b1d29 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/lto/bind-c-char_0.f90 @@ -0,0 +1,49 @@ +! { dg-lto-do link } +! { dg-lto-options {{ -O0 -flto }} } +! +! PR fortran/102885 + +module m + use iso_c_binding, only: c_char + implicit none (type, external) + +contains + +! Assumed-shape array, nonallocatable/nonpointer + +subroutine ar3 (xn, n) bind(C) + integer :: n + character(len=n) :: xn(..) + if (size(xn) /= 6) stop + if (len(xn) /= 5) stop + select rank(xn) + rank(1) + xn = ['FDGhf', & + 'hdrhg', & + 'fDgFl', & + 'DFHs3', & + '4a54G', & + 'hSs6k'] + rank default + stop + end select +end + +end + +program main + use m + implicit none (type, external) + character(kind=c_char, len=5) :: str5a6(6) + + ! assumed rank - with array descriptor + + str5a6 = ['DDGhf', & + 'hdrh$', & + 'fDGSl', & + 'DFHs3', & + '43grG', & + 'hFG$k'] + call ar3 (str5a6, 5) + +end
reply other threads:[~2021-10-26 14:11 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=20211026141117.0A08B3858C3A@sourceware.org \ --to=burnus@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).