From: "José Rui Faustino de Sousa" <jrfsousa@gmail.com>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [Patch, fortran] PR fortran/100024 PR fortran/100025 ICE on subroutine missing explicit interface
Date: Sat, 10 Apr 2021 21:18:13 +0000 [thread overview]
Message-ID: <a90391c3-b543-d58d-4e61-7a865e6dd5fe@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 734 bytes --]
Hi all!
Proposed patch to PR100024 & PR100025 - ICE on missing polymorphic argument.
Patch tested only on x86_64-pc-linux-gnu.
Remove assertion checking for possible assumed rank arrays and added an
explicit error message.
Change if clause to allow the handling of assumed-rank arrays as arrays.
Thank you very much.
Best regards,
José Rui
Fortran: Fix ICE on the handling of assumed-rank procedures
[PR100024/PR100025]
gcc/fortran/ChangeLog:
* interface.c (argument_rank_mismatch): Remove assertion and add
an explicit error message.
(gfc_get_formal_from_actual_arglist): Allow handling of
assume-rank arrays.
gcc/testsuite/ChangeLog:
* gfortran.dg/PR100024.f90: New test.
* gfortran.dg/PR100025.f90: New test.
[-- Attachment #2: PR100025.patch --]
[-- Type: text/x-patch, Size: 2546 bytes --]
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 60736123550..5868bf23f11 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -2237,8 +2237,11 @@ argument_rank_mismatch (const char *name, locus *where,
}
else
{
- gcc_assert (rank2 != -1);
- if (rank1 == 0)
+ if (rank2 == -1)
+ gfc_error_opt (0, "The assumed-rank array actual argument at %L and "
+ "actual argument at %L are ambiguous, an explicit "
+ "interface is required.", where, where_formal);
+ else if (rank1 == 0)
gfc_error_opt (0, "Rank mismatch between actual argument at %L "
"and actual argument at %L (scalar and rank-%d)",
where, where_formal, rank2);
@@ -5358,7 +5361,7 @@ gfc_get_formal_from_actual_arglist (gfc_symbol *sym,
s->ts.is_iso_c = 0;
s->ts.is_c_interop = 0;
s->attr.flavor = FL_VARIABLE;
- if (a->expr->rank > 0)
+ if (a->expr->rank)
{
s->attr.dimension = 1;
s->as = gfc_get_array_spec ();
diff --git a/gcc/testsuite/gfortran.dg/PR100024.f90 b/gcc/testsuite/gfortran.dg/PR100024.f90
new file mode 100644
index 00000000000..fe82ef6da0a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR100024.f90
@@ -0,0 +1,37 @@
+! { dg-do compile }
+!
+program foobar
+
+ implicit none
+
+ type :: foo_t
+ end type foo_t
+
+ class(foo_t), pointer :: a
+ type(foo_t), target :: b
+
+ call bar1(a)
+ call bar2(b)
+ stop
+
+contains
+
+ subroutine bar1(this)
+ class(foo_t), pointer, intent(in) :: this(..)
+
+ call foo(this)
+ return
+ end subroutine bar1
+
+ subroutine bar2(this)
+ type(foo_t), pointer, intent(in) :: this(..)
+
+ call foo(this)
+ return
+ end subroutine bar2
+
+end program foobar
+! { dg-error "Explicit interface required for polymorphic argument at \\\(1\\\)" "" { target "*-*-*" } 22 }
+! { dg-excess-errors "" }
+
+
diff --git a/gcc/testsuite/gfortran.dg/PR100025.f90 b/gcc/testsuite/gfortran.dg/PR100025.f90
new file mode 100644
index 00000000000..ef8b58ad94a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR100025.f90
@@ -0,0 +1,25 @@
+! { dg-do compile }
+!
+program foo_p
+
+ implicit none
+
+ class(*), pointer :: a
+
+ call foo(a)
+ call sub_s(a)
+ stop
+
+contains
+
+ subroutine bar_s(this)
+ class(*), intent(in) :: this(..)
+
+ call foo(this)
+ return
+ end subroutine bar_s
+
+end program foo_p
+! { dg-error "Explicit interface required for polymorphic argument at \\\(1\\\)" "" { target "*-*-*" } 10 }
+! { dg-excess-errors "" }
+
reply other threads:[~2021-04-10 21:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=a90391c3-b543-d58d-4e61-7a865e6dd5fe@gmail.com \
--to=jrfsousa@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).