From: Paul Richard Thomas <paul.richard.thomas@gmail.com>
To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array
Date: Fri, 31 Jul 2020 16:44:23 +0100 [thread overview]
Message-ID: <CAGkQGiJGLSd7J1TP_PjuTJ9AEfPZ0-swqxSreOx9i6jpDL5XEQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 804 bytes --]
Hi All,
This is my first foray into gfortran for quite a little while so I am going
cautiously on this 'obvious' patch. The comment in the patch and the
ChangLog are clear enough that no further explanation is needed.
Regtests on FC31.x86_64 - OK for trunk?
I am a bit reluctant to get into backporting just yet because I am still
groping my way round git. However, I will do it when I feel a bit braver!
Regards
Paul
2020-07-31 Paul Thomas <pault@gcc.gnu.org>
PR fortran/96320
* interface.c (gfc_check_dummy_characteristics): If a module
procedure arrives with assumed shape in the interface and
deferred shape in the procedure itself, update the latter and
copy the lower bounds.
2020-07-31 Paul Thomas <pault@gcc.gnu.org>
PR fortran/96320
* gfortran.dg/module_procedure_4.f90 : New test.
[-- Attachment #2: submit.diff --]
[-- Type: application/x-patch, Size: 1865 bytes --]
[-- Attachment #3: module_procedure_4.f90 --]
[-- Type: text/x-fortran, Size: 1460 bytes --]
! { dg-do run }
!
! Test the fix for PR96320 in which the assumed shape of 'arg' in the
! interface for 'bar' was mirrored by the 'arg' in the module procedure
! incorrectly have deferred shape.
!
! Contributed by Damian Rouson <damian@sourceryinstitute.org>
!
module foobar
type foo
contains
procedure, nopass :: bar1
procedure, nopass :: bar2
procedure, nopass :: bar3
end type
interface
module subroutine bar1(arg)
character(len=*) arg(:)
end subroutine
module subroutine bar2(arg)
character(len=*) arg(3:)
end subroutine
module subroutine bar3(arg)
character(len=*) arg(2)
end subroutine
end interface
contains
module procedure bar1
if (lbound(arg, 1) .ne. 1) stop 1
if (arg(3) .ne. 'hijk') stop 2
end procedure
! Make sure that the lower bound of an assumed shape array dummy,
! if defined, is passed to the module procedure.
module procedure bar2
if (lbound(arg, 1) .ne. 3) stop 3
if (arg(3) .ne. 'abcd') stop 4
end procedure
! This makes sure that an dummy with explicit shape has the upper
! bound correctly set in the module procedure.
module procedure bar3
if (lbound(arg, 1) .ne. 1) stop 5
if (arg(3) .ne. 'hijk') stop 6 ! { dg-warning "is out of bounds" }
end procedure
end module
use foobar
character(4) :: list(3) = ['abcd', 'efgh' , 'hijk']
type(foo) :: f
call f%bar1(list)
call f%bar2(list)
call f%bar3(list)
end
next reply other threads:[~2020-07-31 15:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-31 15:44 Paul Richard Thomas [this message]
2020-08-01 9:54 ` Thomas Koenig
2020-08-01 10:16 ` Paul Richard Thomas
2021-01-06 20:23 Paul Richard Thomas
2021-01-06 20:24 ` Paul Richard Thomas
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=CAGkQGiJGLSd7J1TP_PjuTJ9AEfPZ0-swqxSreOx9i6jpDL5XEQ@mail.gmail.com \
--to=paul.richard.thomas@gmail.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@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: link
Be 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).