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 r11-10594] Fortran: procedures with BIND(C) attribute require explicit interface [PR85877] Date: Fri, 24 Mar 2023 18:41:45 +0000 (GMT) [thread overview] Message-ID: <20230324184145.3D5E93858D1E@sourceware.org> (raw) https://gcc.gnu.org/g:0257ba766443f11cf61c52db9b480337e44b48c8 commit r11-10594-g0257ba766443f11cf61c52db9b480337e44b48c8 Author: Harald Anlauf <anlauf@gmx.de> Date: Fri Mar 17 22:24:49 2023 +0100 Fortran: procedures with BIND(C) attribute require explicit interface [PR85877] gcc/fortran/ChangeLog: PR fortran/85877 * resolve.c (resolve_fl_procedure): Check for an explicit interface of procedures with the BIND(C) attribute (F2018:15.4.2.2). gcc/testsuite/ChangeLog: PR fortran/85877 * gfortran.dg/pr85877.f90: New test. (cherry picked from commit 5426ab34643d9e6502f3ee572891a03471fa33ed) Diff: --- gcc/fortran/resolve.c | 10 ++++++++++ gcc/testsuite/gfortran.dg/pr85877.f90 | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 939b740df61..155005d30bb 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -13516,6 +13516,16 @@ check_formal: } } } + + /* F2018:15.4.2.2 requires an explicit interface for procedures with the + BIND(C) attribute. */ + if (sym->attr.is_bind_c && sym->attr.if_source == IFSRC_UNKNOWN) + { + gfc_error ("Interface of %qs at %L must be explicit", + sym->name, &sym->declared_at); + return false; + } + return true; } diff --git a/gcc/testsuite/gfortran.dg/pr85877.f90 b/gcc/testsuite/gfortran.dg/pr85877.f90 new file mode 100644 index 00000000000..d8f08cbd210 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr85877.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! PR fortran/85877 +! A procedure with the bind(c) attribute shall have an explicit interface +! Contributed by G. Steinmetz + +function f() bind(c) + f = 42. +end + +subroutine p + bind(c) f ! { dg-error "must be explicit" } + x = f() +end + +function g() bind(c) + g = 42. +end + +subroutine s + interface + function g() bind(c) + end function g + end interface + x = g() +end
reply other threads:[~2023-03-24 18:41 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=20230324184145.3D5E93858D1E@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).