public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Richard Thomas <paul.richard.thomas@gmail.com>
To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>
Subject: Re: [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array
Date: Wed, 6 Jan 2021 20:24:42 +0000	[thread overview]
Message-ID: <CAGkQGiLmDXrHcdnV+j2RURT-P+jccijm3_jWyT8kUrsW-KSQcw@mail.gmail.com> (raw)
In-Reply-To: <CAGkQGiJbDd00jn15MsKGPj8sh43h=TM8X9q4CgzYDBABdZZ-nw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1269 bytes --]

Sorry, the testcases were left off.

Paul


On Wed, 6 Jan 2021 at 20:23, Paul Richard Thomas <
paul.richard.thomas@gmail.com> wrote:

> This patch fixes the problems in comments 23 and 24 of the PR.
>
> Comment 23 is fixed by the chunk in expr.c. The chunks in decl.c and
> resolve.c fix #24. To be quite honest, I am not sure why they were not
> needed in the first place! However, the changes don't cause any problems.
> Removing the interface bodies causes the expected error cascade.
>
> Regtests on FC33/x86_64 - OK for master and, after a decent delay 9- and
> 10- branches?
>
> Paul
>
> Fortran: This patch fixes comments 23 and 24 of PR96320.
>
> 2021-01-06  Paul Thomas  <pault@gcc.gnu.org>
>
> gcc/fortran
> PR fortran/96320
> * decl.c (gfc_match_modproc): It is not an error to find a
> module procedure declaration within a contains block.
> * expr.c (gfc_check_vardef_context): Pure procedure result is
> assignable. Change 'own_scope' accordingly.
> * resolve.c (resolve_typebound_procedure): A procedure that
> has the module procedure attribute is almost certainly a
> module procedure, whatever its interface.
>
> gcc/testsuite/
> PR fortran/96320
> * gfortran.dg/module_procedure_5.f90 : New test.
> * gfortran.dg/module_procedure_6.f90 : New test.
>

[-- Attachment #2: module_procedure_5.f90 --]
[-- Type: text/x-fortran, Size: 604 bytes --]

! { dg-do compile }
!
! Test the fix for the testcase in comment 23 of PR96320, which used to
! fail with the message: Variable ‘new_foo’ cannot appear in a variable
! definition context.
!
! Contributed by Damian Rouson  <damian@sourceryinstitute.org>
!
module foobar
  implicit none

  type foo
    integer bar
  end type

  interface
    pure module function create() result(new_foo)
      implicit none
      type(foo) new_foo
    end function
  end interface

contains
  module procedure create
    new_foo%bar = 1  ! Error here
  end procedure
end module

  use foobar
  print *, create ()
end

[-- Attachment #3: module_procedure_6.f90 --]
[-- Type: text/x-fortran, Size: 1421 bytes --]

! { dg-do run }
!
! Test the fix for the testcase in comment 24 of PR96320, which used to
! fail with the message: ‘set_user_defined’ must be a module procedure or
! an external procedure with an explicit interface at (1)
!
! Contributed by Damian Rouson  <damian@sourceryinstitute.org>
!
module hole_interface
  type hole_t
    integer :: user_defined
    real :: hole_diameter
  contains
    procedure set_user_defined
    procedure set_diameter
  end type

  interface
    module subroutine set_diameter (this, diameter)
      class(hole_t) :: this
      real :: diameter
    end subroutine

    module subroutine set_user_defined(this, user_defined)
      class(hole_t) :: this
      integer :: user_defined
    end subroutine
  end interface

contains
  module procedure set_user_defined
    this%user_defined = user_defined
  end procedure

  module procedure set_diameter
    this%hole_diameter = diameter
    if (this%user_defined .lt. 0) then
      call this%set_user_defined (0)
    end if
  end procedure
end module

  use hole_interface ! Error was here
  type (hole_t) :: ht = hole_t (-1, 0.0)
  call ht%set_diameter(1.0)
  if ((ht%user_defined .ne. 0) .and. (ht%hole_diameter .ne. 1.0)) stop 1
  call ht%set_user_defined (5)
  if ((ht%user_defined .ne. 5) .and. (ht%hole_diameter .ne. 1.0)) stop 2
  call ht%set_diameter(2.0)
  if ((ht%user_defined .ne. 5) .and. (ht%hole_diameter .ne. 2.0)) stop 3
end

  reply	other threads:[~2021-01-06 20:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 20:23 Paul Richard Thomas
2021-01-06 20:24 ` Paul Richard Thomas [this message]
2021-01-14 21:45 ` Ping: " Paul Richard Thomas
2021-01-15  9:03   ` Un-Ping: " Paul Richard Thomas
  -- strict thread matches above, loose matches on Subject: below --
2020-07-31 15:44 Paul Richard Thomas
2020-08-01  9:54 ` Thomas Koenig
2020-08-01 10:16   ` 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=CAGkQGiLmDXrHcdnV+j2RURT-P+jccijm3_jWyT8kUrsW-KSQcw@mail.gmail.com \
    --to=paul.richard.thomas@gmail.com \
    --cc=fortran@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).