public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-8942] Fortran: reject NULL actual argument without explicit interface [PR107576] Date: Fri, 25 Nov 2022 22:19:13 +0000 (GMT) [thread overview] Message-ID: <20221125221913.1DB9B384F489@sourceware.org> (raw) https://gcc.gnu.org/g:2a7a103dd46cc079252302be69cfef188caee74d commit r12-8942-g2a7a103dd46cc079252302be69cfef188caee74d 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.cc (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.cc | 8 ++++++++ gcc/testsuite/gfortran.dg/null_actual_3.f90 | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc index 71eec78259b..0acd78d5f2e 100644 --- a/gcc/fortran/interface.cc +++ b/gcc/fortran/interface.cc @@ -4137,6 +4137,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
reply other threads:[~2022-11-25 22:19 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=20221125221913.1DB9B384F489@sourceware.org \ --to=anlauf@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: linkBe 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).