public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-6322] Fortran: Fix ICE in argument_rank_mismatch [PR103287]
Date: Thu,  6 Jan 2022 20:46:22 +0000 (GMT)	[thread overview]
Message-ID: <20220106204622.995FA3858408@sourceware.org> (raw)

https://gcc.gnu.org/g:8e2771069ed0c157cca825d6af5792e94c4407c1

commit r12-6322-g8e2771069ed0c157cca825d6af5792e94c4407c1
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Wed Jan 5 13:18:10 2022 -0800

    Fortran: Fix ICE in argument_rank_mismatch [PR103287]
    
    This patch removes an incorrect assertion.  A user-friendly error for this
    case is already given elsewhere.
    
    2022-01-05  Steve Kargl  <kargl@gcc.gnu.org>
                Sandra Loosemore  <sandra@codesourcery.com>
    
            PR fortran/103287
    
            gcc/fortran/
            * interface.c (argument_rank_mismatch): Replace incorrect assertion
            with return.
    
            gcc/testsuite/
            * gfortran.dg/c-interop/pr103287-1.f90: new.
            * gfortran.dg/c-interop/pr103287-2.f90: new.

Diff:
---
 gcc/fortran/interface.c                            | 6 +++++-
 gcc/testsuite/gfortran.dg/c-interop/pr103287-1.f90 | 9 +++++++++
 gcc/testsuite/gfortran.dg/c-interop/pr103287-2.f90 | 9 +++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 4be95834def..0fd881dec15 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -2237,7 +2237,11 @@ argument_rank_mismatch (const char *name, locus *where,
     }
   else
     {
-      gcc_assert (rank2 != -1);
+      if (rank2 == -1)
+	/* This is an assumed rank-actual passed to a function without
+	   an explicit interface, which is already diagnosed in
+	   gfc_procedure_use.  */
+	return;
       if (rank1 == 0)
 	gfc_error_opt (0, "Rank mismatch between actual argument at %L "
 		       "and actual argument at %L (scalar and rank-%d)",
diff --git a/gcc/testsuite/gfortran.dg/c-interop/pr103287-1.f90 b/gcc/testsuite/gfortran.dg/c-interop/pr103287-1.f90
new file mode 100644
index 00000000000..aeca52f01da
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/c-interop/pr103287-1.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+
+subroutine g
+   call s([1])
+end
+subroutine h(x)
+   integer, pointer :: x(..)
+   call s(x) ! { dg-error "Assumed-rank argument requires an explicit interface" } 
+end
diff --git a/gcc/testsuite/gfortran.dg/c-interop/pr103287-2.f90 b/gcc/testsuite/gfortran.dg/c-interop/pr103287-2.f90
new file mode 100644
index 00000000000..0e724b8fa47
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/c-interop/pr103287-2.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+
+subroutine g
+   call s(1)
+end
+subroutine h(x)
+   integer, pointer :: x(..)
+   call s(x) ! { dg-error "Assumed-rank argument requires an explicit interface" } 
+end


                 reply	other threads:[~2022-01-06 20:46 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=20220106204622.995FA3858408@sourceware.org \
    --to=sandra@gcc.gnu.org \
    --cc=gcc-cvs@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).