diff options
author | Steve Kargl <kargl@gcc.gnu.org> | 2022-12-10 22:17:15 +0100 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2022-12-11 20:34:17 +0100 |
commit | 8f72249ff4cbd0a5c701b99ee8aa1ca9d82df046 (patch) | |
tree | 1c768cfa527430095af6614313f68b17c8627568 | |
parent | d9d8c9674ad3ad3aa38419d24b1aaaffe31f5d3f (diff) | |
download | gcc-8f72249ff4cbd0a5c701b99ee8aa1ca9d82df046.zip gcc-8f72249ff4cbd0a5c701b99ee8aa1ca9d82df046.tar.gz gcc-8f72249ff4cbd0a5c701b99ee8aa1ca9d82df046.tar.bz2 |
Fortran: fix ICE on bad use of statement function [PR107995]
gcc/fortran/ChangeLog:
PR fortran/107995
* interface.cc (gfc_check_dummy_characteristics): Reject statement
function dummy arguments.
gcc/testsuite/ChangeLog:
PR fortran/107995
* gfortran.dg/pr107995.f90: New test.
-rw-r--r-- | gcc/fortran/interface.cc | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr107995.f90 | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc index 73799c1..7d8eeda 100644 --- a/gcc/fortran/interface.cc +++ b/gcc/fortran/interface.cc @@ -1334,6 +1334,12 @@ gfc_check_dummy_characteristics (gfc_symbol *s1, gfc_symbol *s2, if (s1 == NULL || s2 == NULL) return s1 == s2 ? true : false; + if (s1->attr.proc == PROC_ST_FUNCTION || s2->attr.proc == PROC_ST_FUNCTION) + { + strncpy (errmsg, "Statement function", err_len); + return false; + } + /* Check type and rank. */ if (type_must_agree) { diff --git a/gcc/testsuite/gfortran.dg/pr107995.f90 b/gcc/testsuite/gfortran.dg/pr107995.f90 new file mode 100644 index 0000000..22e8786 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr107995.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/107995 +! Contributed by G.Steinmetz + +program p + implicit none + integer :: n ! { dg-error "Self-referential argument" } + n(n) = 1 ! { dg-warning "Statement function" } + print *, n(n) ! { dg-error "Statement function" } +end |