public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <tobias@codesourcery.com>
To: Paul Richard Thomas <paul.richard.thomas@gmail.com>,
	"fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Juergen Reuter <juergen.reuter@physik.uni-freiburg.de>,
	Harald Anlauf <anlauf@gmx.de>
Subject: Re: [Patch, fortran] PR99602 - [11 regression] runtime error: pointer actual argument not associated
Date: Tue, 16 Mar 2021 18:08:22 +0100	[thread overview]
Message-ID: <4ee532b7-eed8-8dd7-4e01-9a2e8004007c@codesourcery.com> (raw)
In-Reply-To: <CAGkQGi+mLLMim_WcfD1kbR9KARb1f5Gngg=nE9Sax1Po=aMG0g@mail.gmail.com>

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

Hi Paul,

On 16.03.21 17:42, Paul Richard Thomas via Gcc-patches wrote:
> Fortran: Fix runtime errors for class actual arguments [PR99602].
> * trans-array.c (gfc_conv_procedure_call): For class formal
> arguments, use the _data field attributes for runtime errors.
> * gfortran.dg/pr99602.f90: New test.

Shouldn't there be also a testcase which triggers this run-time error?

I might have messed up my testcase, but I think it should trigger?
(Attached is an attempt to pass the nullified pointer as actual argument
to a non-pointer argument; otherwise it is the same testcase as before.)

Otherwise, at a glance, it looked sensible.

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf

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

! { dg-do compile }
! { dg-options "-fcheck=pointer -fdump-tree-original" }
!
! Test fix of PR99602, where a spurious runtime error was introduced
! by PR99112. This is the testcase in comment #6 of the PR.
!
! Contributed by Jeurgen Reuter  <juergen.reuter@desy.de>
!
module m
  implicit none
  private
  public :: m_t
  type :: m_t
     integer :: ii(100)
  end type m_t
end module m

module m2_testbed
  use m
  implicit none
  private
  public :: prepare_m2
  procedure (prepare_m2_proc), pointer :: prepare_m2 => null ()

  abstract interface
     subroutine prepare_m2_proc (m2)
       import
       class(m_t), intent(inout) :: m2
     end subroutine prepare_m2_proc
  end interface

end module m2_testbed

module a
  use m
  use m2_testbed, only: prepare_m2
  implicit none
  private
  public :: a_1

contains

  subroutine a_1 ()
    class(m_t), pointer :: mm
    mm => null ()
    call prepare_m2 (mm) ! Runtime error triggered here
  end subroutine a_1

end module a


module m2
  use m
  implicit none
  private
  public :: m2_t

  type, extends (m_t) :: m2_t
     private
   contains
     procedure :: read => m2_read
  end type m2_t
contains

  subroutine m2_read (mm)
    class(m2_t), intent(out), target :: mm
  end subroutine m2_read
end module m2

program main
  use m2_testbed
  use a, only: a_1
  implicit none
  prepare_m2 => prepare_whizard_m2
  call a_1 ()

contains

  subroutine prepare_whizard_m2 (mm)
    use m
    use m2
    class(m_t), intent(inout) :: mm
    !if (.not. associated (mm))  allocate (m2_t :: mm)
    mm%ii = 100
    select type (mm)
    type is (m2_t)
       call mm%read ()
    end select
  end subroutine prepare_whizard_m2
end program main
! { dg-final { scan-tree-dump-times "_gfortran_runtime_error_at" 0 "original" } }
! { dg-final { scan-tree-dump-times "Pointer actual argument" 0 "original" } }

  reply	other threads:[~2021-03-16 17:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16 16:42 Paul Richard Thomas
2021-03-16 17:08 ` Tobias Burnus [this message]
2021-03-16 20:26   ` Aw: " Harald Anlauf
2021-03-18  8:46   ` Tobias Burnus
2021-03-18 13:22     ` Paul Richard Thomas
2021-03-26  6:58 Paul Richard Thomas
2021-03-26 11:22 ` Tobias Burnus
2021-03-29  9:15   ` 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=4ee532b7-eed8-8dd7-4e01-9a2e8004007c@codesourcery.com \
    --to=tobias@codesourcery.com \
    --cc=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=juergen.reuter@physik.uni-freiburg.de \
    --cc=paul.richard.thomas@gmail.com \
    /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).