Aw: Re: [Patch, fortran] PR99602 - [11 regression] runtime error: pointer actual argument not associated

2021-03-16 Thread Harald Anlauf via Fortran
Hi Tobias,

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

The testcase is there, it simply has the wrong dg-foo:

! { dg-do compile }

which should be

! { dg-do run }

*-*-*

There are certainly more cases which should insert checks but currently don't, 
like:

subroutine p (mm)
  implicit none
  type :: m_t
  end type m_t
  type, extends (m_t) :: m2_t
  end type m2_t
  class(m_t), pointer :: mm
  select type (mm)
  type is (m2_t)
 print *, "m2_t"
  end select
end

We've still two or three weeks to solve this before 11-release!  :-)

Harald



Re: [Patch, fortran] PR99602 - [11 regression] runtime error: pointer actual argument not associated

2021-03-16 Thread Tobias Burnus

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


[Patch, fortran] PR99602 - [11 regression] runtime error: pointer actual argument not associated

2021-03-16 Thread Paul Richard Thomas via Fortran
Hi Everybody,

Although this is 'obvious' I thought that I should post it because I
believe that it was triggered by the fix for PR99602 but I just do not have
the bandwidth at the moment to test that. The ChangeLog together with the
patch is more than sufficient explanation.

Regtests OK on FC33/x86_64. OK for 11-branch?

Paul

Fortran: Fix runtime errors for class actual arguments [PR99602].

2021-03-16  Paul Thomas  

gcc/fortran
PR fortran/99602
* trans-array.c (gfc_conv_procedure_call): For class formal
arguments, use the _data field attributes for runtime errors.

gcc/testsuite/
PR fortran/99602
* gfortran.dg/pr99602.f90: New test.
! { 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  
!
module m
  implicit none
  private
  public :: m_t
  type :: m_t
 private
  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), pointer :: 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), pointer :: mm
if (.not. associated (mm))  allocate (m2_t :: mm)
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" } }
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index bffe0808dff..0cf17008b05 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -6663,6 +6663,15 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  char *msg;
 	  tree cond;
 	  tree tmp;
+	  symbol_attribute fsym_attr;
+
+	  if (fsym)
+	{
+	  if (fsym->ts.type == BT_CLASS && !UNLIMITED_POLY (fsym))
+		fsym_attr = CLASS_DATA (fsym)->attr;
+	  else
+		fsym_attr = fsym->attr;
+	}
 
 	  if (e->expr_type == EXPR_VARIABLE || e->expr_type == EXPR_FUNCTION)
 	attr = gfc_expr_attr (e);
@@ -6685,17 +6694,17 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  tree present, null_ptr, type;
 
 	  if (attr.allocatable
-		  && (fsym == NULL || !fsym->attr.allocatable))
+		  && (fsym == NULL || !fsym_attr.allocatable))
 		msg = xasprintf ("Allocatable actual argument '%s' is not "
  "allocated or not present",
  e->symtree->n.sym->name);
 	  else if (attr.pointer
-		   && (fsym == NULL || !fsym->attr.pointer))
+		   && (fsym == NULL || !fsym_attr.pointer))
 		msg = xasprintf ("Pointer actual argument '%s' is not "
  "associated or not present",
  e->symtree->n.sym->name);
 	  else if (attr.proc_pointer
-		   && (fsym == NULL || !fsym->attr.proc_pointer))
+		   && (fsym == NULL || !fsym_attr.proc_pointer))
 		msg = xasprintf ("Proc-pointer actual argument '%s' is not "
  "associated or not present",
  e->symtree->n.sym->name);
@@ -6719,15 +6728,15 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
   else
 	{
 	  if (attr.allocatable
-		  && (fsym == NULL || !fsym->attr.allocatable))
+		  && (fsym == NULL || !fsym_attr.allocatable))
 		msg = xasprintf ("Allocatable actual argument '%s' is not "
  "allocated", e->symtree->n.sym->name);
 	  else if (attr.pointer
-		   && (fsym == NULL || !fsym->attr.pointer))
+		   && (fsym == NULL || !fsym_attr.pointer))
 		msg = xasprintf ("Pointer actual argument '%s' is not "
  "associated", e->symtree->n.sym->name);
 	  else if (attr.proc_pointer
-		   && (fsym == NULL || !fsym->attr.proc_pointer))
+		   && (fsym == NULL || !fsym_attr.proc_pointer))
 		msg = xasprintf ("Proc-pointer actual argument '%s' is not "
  "associated", e->symtree->n.sym->name);
 	  else


Fwd: GCC 11.0.1 Status Report (2021-03-16)

2021-03-16 Thread Toon Moene

For Your Information ...


 Forwarded Message 
Subject: GCC 11.0.1 Status Report (2021-03-16)
Date: Tue, 16 Mar 2021 12:19:20 +0100 (CET)
From: Richard Biener 
Reply-To: g...@gcc.gnu.org
To: g...@gcc.gnu.org
CC: gcc-patc...@gcc.gnu.org


Status
==

GCC trunk which eventually will become GCC 11 is still in
regression and documentation fixes only mode (Stage 4).

If history should repeat itself then a first release candidate
of GCC 11 will be released mid April.  For this to happen
we need to resolve the remaining 17 P1 regressions - 8 of which
are classified as target or bootstrap issues.  Please have
a look at the set of P1 (and preferably also P2) regressions
which can be conveniently accessed via the 'Serious regressions'
link on https://gcc.gnu.org


Quality Data


Priority  #   Change from last report
---   ---
P1   17   - 45
P2  288   - 46
P3   37   +  1
P4  192   +  2
P5   24
---   ---
Total P1-P3 342   - 90
Total   558   - 88


Previous Report
===

https://gcc.gnu.org/pipermail/gcc/2021-January/234703.html