diff options
author | Sandra Loosemore <sandra@codesourcery.com> | 2022-01-05 13:18:10 -0800 |
---|---|---|
committer | Sandra Loosemore <sandra@codesourcery.com> | 2022-01-06 12:45:56 -0800 |
commit | 8e2771069ed0c157cca825d6af5792e94c4407c1 (patch) | |
tree | b4baee38d00056b0bed1d4a4007e80e5a02ec796 | |
parent | c2e5c4feed32c808591b5278f680bbabe63eb225 (diff) | |
download | gcc-8e2771069ed0c157cca825d6af5792e94c4407c1.zip gcc-8e2771069ed0c157cca825d6af5792e94c4407c1.tar.gz gcc-8e2771069ed0c157cca825d6af5792e94c4407c1.tar.bz2 |
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.
-rw-r--r-- | gcc/fortran/interface.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/c-interop/pr103287-1.f90 | 9 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/c-interop/pr103287-2.f90 | 9 |
3 files changed, 23 insertions, 1 deletions
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 4be9583..0fd881d 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 0000000..aeca52f --- /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 0000000..0e724b8 --- /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 |