public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10394] Fortran: reject NULL actual argument without explicit interface [PR107576]
@ 2022-11-25 22:27 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-11-25 22:27 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:55e5ef55a0eee1cb329754f30889d93567daae18
commit r11-10394-g55e5ef55a0eee1cb329754f30889d93567daae18
Author: Harald Anlauf <anlauf@gmx.de>
Date: Thu Nov 17 21:36:49 2022 +0100
Fortran: reject NULL actual argument without explicit interface [PR107576]
gcc/fortran/ChangeLog:
PR fortran/107576
* interface.c (gfc_procedure_use): Reject NULL as actual argument
when there is no explicit procedure interface.
gcc/testsuite/ChangeLog:
PR fortran/107576
* gfortran.dg/null_actual_3.f90: New test.
(cherry picked from commit 820c25c83561085f54268bd536f9d216d03c3e18)
Diff:
---
gcc/fortran/interface.c | 8 ++++++++
gcc/testsuite/gfortran.dg/null_actual_3.f90 | 18 ++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index b7294cbeb4e..bcc835513d4 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -3976,6 +3976,14 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
return false;
}
+ if (a->expr && a->expr->expr_type == EXPR_NULL)
+ {
+ gfc_error ("Passing intrinsic NULL as actual argument at %L "
+ "requires an explicit interface", &a->expr->where);
+ a->expr->error = 1;
+ return false;
+ }
+
/* TS 29113, C407b. */
if (a->expr && a->expr->expr_type == EXPR_VARIABLE
&& symbol_rank (a->expr->symtree->n.sym) == -1)
diff --git a/gcc/testsuite/gfortran.dg/null_actual_3.f90 b/gcc/testsuite/gfortran.dg/null_actual_3.f90
new file mode 100644
index 00000000000..ea49f9630c9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/null_actual_3.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-fallow-argument-mismatch -w" }
+! PR fortran/107576
+! Contributed by G.Steinmetz
+
+program p
+ implicit none
+ interface
+ subroutine r(y)
+ integer, pointer :: y(:)
+ end subroutine r
+ end interface
+ integer, pointer :: z(:) => null()
+ call r(z)
+ call s(z)
+ call r(null(z))
+ call s(null(z)) ! { dg-error "requires an explicit interface" }
+end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-25 22:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 22:27 [gcc r11-10394] Fortran: reject NULL actual argument without explicit interface [PR107576] Harald Anlauf
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).