* [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
* Re: [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array
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
1 sibling, 0 replies; 7+ messages in thread
From: Paul Richard Thomas @ 2021-01-06 20:24 UTC (permalink / raw)
To: fortran
[-- 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Ping: [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array
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 ` Paul Richard Thomas
2021-01-15 9:03 ` Un-Ping: " Paul Richard Thomas
1 sibling, 1 reply; 7+ messages in thread
From: Paul Richard Thomas @ 2021-01-14 21:45 UTC (permalink / raw)
To: fortran
Ping!
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.
>
--
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein
^ permalink raw reply [flat|nested] 7+ messages in thread
* Un-Ping: [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array
2021-01-14 21:45 ` Ping: " Paul Richard Thomas
@ 2021-01-15 9:03 ` Paul Richard Thomas
0 siblings, 0 replies; 7+ messages in thread
From: Paul Richard Thomas @ 2021-01-15 9:03 UTC (permalink / raw)
To: fortran
[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]
Thomas points out that the attachments went AWOL - apologies.
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-15 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: submit2.diff --]
[-- Type: text/x-patch, Size: 1732 bytes --]
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 4771b591f1a..723915822f3 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -9856,7 +9856,8 @@ gfc_match_modproc (void)
gfc_namespace *module_ns;
gfc_interface *old_interface_head, *interface;
- if (gfc_state_stack->state != COMP_INTERFACE
+ if ((gfc_state_stack->state != COMP_INTERFACE
+ && gfc_state_stack->state != COMP_CONTAINS)
|| gfc_state_stack->previous == NULL
|| current_interface.type == INTERFACE_NAMELESS
|| current_interface.type == INTERFACE_ABSTRACT)
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 188e79669cb..4f456fc629a 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -6243,6 +6243,9 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
/* Variable not assignable from a PURE procedure but appears in
variable definition context. */
+ own_scope = own_scope
+ || (sym->attr.result && sym->ns->proc_name
+ && sym == sym->ns->proc_name->result);
if (!pointer && !own_scope && gfc_pure (NULL) && gfc_impure_variable (sym))
{
if (context)
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index fa6f756d285..2cb009f8cef 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -14016,7 +14016,8 @@ resolve_typebound_procedure (gfc_symtree* stree)
/* Check for F08:C465. */
if ((!proc->attr.subroutine && !proc->attr.function)
|| (proc->attr.proc != PROC_MODULE
- && proc->attr.if_source != IFSRC_IFBODY)
+ && proc->attr.if_source != IFSRC_IFBODY
+ && !proc->attr.module_procedure)
|| proc->attr.abstract)
{
gfc_error ("%qs must be a module procedure or an external "
[-- 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
[-- Attachment #4: 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 #5: 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
* Re: [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array
2020-08-01 9:54 ` Thomas Koenig
@ 2020-08-01 10:16 ` Paul Richard Thomas
0 siblings, 0 replies; 7+ messages in thread
From: Paul Richard Thomas @ 2020-08-01 10:16 UTC (permalink / raw)
To: Thomas Koenig; +Cc: fortran, gcc-patches
Hi Thomas,
I discovered the bit about the ChangeLogs last night but thanks for the
warning:-)
The commit message reads:
This patch fixes PR96320. See the explanatory comment in the testcase.
2020-08-01 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR target/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.
gcc/testsuite/
PR target/96320
* gfortran.dg/module_procedure_4.f90 : New test.
Setting standard F2003 results in a whole pile of errors, starting with:
../pr96320/pr96320.f90:19:12:
19 | module subroutine bar1(arg)
| 1
Error: Fortran 2008: MODULE prefix at (1)
and a bit later:
../pr96320/pr96320.f90:23:12:
23 | module subroutine bar2(arg)
| 1
Error: Fortran 2008: MODULE prefix at (1)
Cheers
Paul
On Sat, 1 Aug 2020 at 10:54, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hi Paul,
>
> > 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?
>
> If I read the PR correctly, this is a F2008 feature. Do you think
> it should have a gfc_option.allow_std & GFC_STD_F2008 somewhere?
>
> Apart from that, 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!
>
> Actually, backporting is not all that bad if the patch applies cleanly.
> I don't know if you have done this recently, but it very much
> makes sense to run
>
> contrib/gcc-git-customization.sh
>
> which will then give you access to commands like "git gcc-backport"
> (there is tab completion) and others.
>
>
> > 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.
>
> With the ChangeLog formatted like this, I am afraid you will
> run afoul of the ChangeLog style police :-(
>
> In the Brave New World of git, you do not commit a ChangeLog
> together with your patch, you put it into the git commit
> message.
>
> It is best if you run your patch through contrib/mklog.py
> to get the template for your commit message. You can then copy
> over the other information.
>
> And you need a one-line description for the patch of at most
> 80 characters, with a period at the end.
>
> And, I think, new test cases are added automatically to the
> ChangeLogs.
>
> The ChangeLog then look something like this:
>
> Fix shape mismatch in assumed-length dummy argument character array.
>
> gcc/fortran/ChangeLog:
>
> 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.
> (compare_parameter): Fix whitespace.
> (gfc_procedure_use): Fix whitespace.
>
>
> If you have already committed something that the ChangeLog style
> police objects to, you can change that with "git commit --amend".
>
> I hope this helps you in avoiding a few iterations of getting rejected
> when pushing a change. I think it covers most of what I went through :-|
>
> (I just discovered that there is a "git gcc-verify" which probably
> does the tests before you push. Maybe that could be helpful.)
>
> Best regards
>
> Thomas
>
--
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [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
2020-08-01 10:16 ` Paul Richard Thomas
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Koenig @ 2020-08-01 9:54 UTC (permalink / raw)
To: Paul Richard Thomas, fortran, gcc-patches
Hi Paul,
> 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?
If I read the PR correctly, this is a F2008 feature. Do you think
it should have a gfc_option.allow_std & GFC_STD_F2008 somewhere?
Apart from that, 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!
Actually, backporting is not all that bad if the patch applies cleanly.
I don't know if you have done this recently, but it very much
makes sense to run
contrib/gcc-git-customization.sh
which will then give you access to commands like "git gcc-backport"
(there is tab completion) and others.
> 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.
With the ChangeLog formatted like this, I am afraid you will
run afoul of the ChangeLog style police :-(
In the Brave New World of git, you do not commit a ChangeLog
together with your patch, you put it into the git commit
message.
It is best if you run your patch through contrib/mklog.py
to get the template for your commit message. You can then copy
over the other information.
And you need a one-line description for the patch of at most
80 characters, with a period at the end.
And, I think, new test cases are added automatically to the
ChangeLogs.
The ChangeLog then look something like this:
Fix shape mismatch in assumed-length dummy argument character array.
gcc/fortran/ChangeLog:
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.
(compare_parameter): Fix whitespace.
(gfc_procedure_use): Fix whitespace.
If you have already committed something that the ChangeLog style
police objects to, you can change that with "git commit --amend".
I hope this helps you in avoiding a few iterations of getting rejected
when pushing a change. I think it covers most of what I went through :-|
(I just discovered that there is a "git gcc-verify" which probably
does the tests before you push. Maybe that could be helpful.)
Best regards
Thomas
^ 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).