From: Paul Richard Thomas <paul.richard.thomas@gmail.com>
To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [Patch, fortran] PR98897 - Erroneous procedure attribute for associate name
Date: Tue, 2 Feb 2021 12:20:21 +0000 [thread overview]
Message-ID: <CAGkQGiKSobUg=WtUHv8UHgHeLM5_3kPLBSmzWV4CzG0808KU7w@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 512 bytes --]
This is more or less 'obvious' and does not require any further explanation.
Regtests with FC33/x86_64 - OK for master (and ....)?
Paul
Fortran: Fix calls to associate name typebound subroutines [PR98897].
2021-02-02 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/98897
* match.c (gfc_match_call): Include associate names as possible
entities with typebound subroutines. The target needs to be
resolved for the type.
gcc/testsuite/
PR fortran/98897
* gfortran.dg/typebound_call_32.f90: New test.
[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 1070 bytes --]
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index f0469e25da6..2df6191d7e6 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -4999,10 +4999,16 @@ gfc_match_call (void)
sym = st->n.sym;
/* If this is a variable of derived-type, it probably starts a type-bound
- procedure call. */
- if ((sym->attr.flavor != FL_PROCEDURE
- || gfc_is_function_return_value (sym, gfc_current_ns))
- && (sym->ts.type == BT_DERIVED || sym->ts.type == BT_CLASS))
+ procedure call. Associate variable targets have to be resolved for the
+ target type. */
+ if (((sym->attr.flavor != FL_PROCEDURE
+ || gfc_is_function_return_value (sym, gfc_current_ns))
+ && (sym->ts.type == BT_DERIVED || sym->ts.type == BT_CLASS))
+ ||
+ (sym->assoc && sym->assoc->target
+ && gfc_resolve_expr (sym->assoc->target)
+ && (sym->assoc->target->ts.type == BT_DERIVED
+ || sym->assoc->target->ts.type == BT_CLASS)))
return match_typebound_call (st);
/* If it does not seem to be callable (include functions so that the
[-- Attachment #3: typebound_call_32.f90 --]
[-- Type: text/x-fortran, Size: 839 bytes --]
! { dg-do run }
!
! Test the fix for PR98897 in which typebound subroutines of associate names
! were not recognised in a call. Functions were OK but this is tested below.
!
! Contributed by Damian Rouson <damian@sourceryinstitute.org>
!
module output_data_m
implicit none
type output_data_t
integer, private :: i = 0
contains
procedure output, return_value
end type
contains
subroutine output(self)
implicit none
class(output_data_t) self
self%i = 1234
end subroutine
integer function return_value(self)
implicit none
class(output_data_t) self
return_value = self%i
end function
end module
use output_data_m
implicit none
associate(output_data => output_data_t())
call output_data%output
if (output_data%return_value() .ne. 1234) stop 1
end associate
end
next reply other threads:[~2021-02-02 12:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 12:20 Paul Richard Thomas [this message]
2021-02-02 13:59 ` Tobias Burnus
2021-02-02 15:05 ` Paul Richard Thomas
2021-02-02 15:56 ` Tobias Burnus
2021-02-12 13:36 ` 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='CAGkQGiKSobUg=WtUHv8UHgHeLM5_3kPLBSmzWV4CzG0808KU7w@mail.gmail.com' \
--to=paul.richard.thomas@gmail.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@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).