public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pault at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/96320] gfortran 8-10 shape mismatch in assumed-length dummy argument character array
Date: Mon, 27 Jul 2020 17:26:14 +0000	[thread overview]
Message-ID: <bug-96320-4-cdYIV98uKm@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96320-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96320

--- Comment #11 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 48935
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48935&action=edit
Proposed patch for the PR

I decided that the best way of proceeding was to correct the array spec and
benefit from the rest of the tests in gfc_check_dummy_characteristics.

My tree is polluted with work on PDTs right now and so I cannot do a full
regtest. However, with the patch applied submodule* and module_procedure* test
just fine as does 'module_procedure_4.f90':

! { 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

  parent reply	other threads:[~2020-07-27 17:26 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-26  4:47 [Bug fortran/96320] New: " damian at sourceryinstitute dot org
2020-07-26 16:34 ` [Bug fortran/96320] " dominiq at lps dot ens.fr
2020-07-26 16:44 ` damian at sourceryinstitute dot org
2020-07-26 16:54 ` dominiq at lps dot ens.fr
2020-07-26 18:43 ` kargl at gcc dot gnu.org
2020-07-26 19:13 ` kargl at gcc dot gnu.org
2020-07-26 21:35 ` jvdelisle at charter dot net
2020-07-27  0:39 ` damian at sourceryinstitute dot org
2020-07-27  0:45 ` sgk at troutmask dot apl.washington.edu
2020-07-27  3:34 ` damian at sourceryinstitute dot org
2020-07-27  7:26 ` pault at gcc dot gnu.org
2020-07-27 11:37 ` dominiq at lps dot ens.fr
2020-07-27 17:26 ` pault at gcc dot gnu.org [this message]
2020-07-27 18:12 ` damian at sourceryinstitute dot org
2020-07-27 19:03 ` dominiq at lps dot ens.fr
2020-07-28  9:24 ` dominiq at lps dot ens.fr
2020-07-28  9:43 ` paul.richard.thomas at gmail dot com
2020-07-28 10:32 ` dominiq at lps dot ens.fr
2020-07-28 14:13 ` sgk at troutmask dot apl.washington.edu
2020-07-28 15:18 ` dominiq at lps dot ens.fr
2020-08-02 10:00 ` cvs-commit at gcc dot gnu.org
2020-08-02 10:05 ` pault at gcc dot gnu.org
2020-08-03 23:45 ` damian at sourceryinstitute dot org
2020-08-04  1:53 ` sgk at troutmask dot apl.washington.edu
2020-08-15  1:59 ` damian at sourceryinstitute dot org
2020-08-20 17:17 ` damian at sourceryinstitute dot org
2020-12-28 14:55 ` cvs-commit at gcc dot gnu.org
2021-01-04 14:42 ` cvs-commit at gcc dot gnu.org
2021-01-04 15:15 ` pault at gcc dot gnu.org
2021-01-21 10:01 ` cvs-commit at gcc dot gnu.org
2023-10-31 14:17 ` pault at gcc dot gnu.org

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=bug-96320-4-cdYIV98uKm@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).