public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array
@ 2021-01-06 20:23 Paul Richard Thomas
  2021-01-06 20:24 ` Paul Richard Thomas
  2021-01-14 21:45 ` Ping: " Paul Richard Thomas
  0 siblings, 2 replies; 7+ messages in thread
From: Paul Richard Thomas @ 2021-01-06 20:23 UTC (permalink / raw)
  To: fortran

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

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: Change2.Logs --]
[-- Type: application/octet-stream, Size: 653 bytes --]

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array
@ 2020-07-31 15:44 Paul Richard Thomas
  2020-08-01  9:54 ` Thomas Koenig
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Richard Thomas @ 2020-07-31 15:44 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-01-15  9:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-06 20:23 [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array Paul Richard Thomas
2021-01-06 20:24 ` Paul Richard Thomas
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

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).