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-9417] Fortran: NULL() is not interoperable Date: Mon, 27 Dec 2021 19:51:09 +0000 (GMT) [thread overview] Message-ID: <20211227195109.C5EC13858404@sourceware.org> (raw) https://gcc.gnu.org/g:a25bfec3aacc34be624a620b00a72719ac03092f commit r11-9417-ga25bfec3aacc34be624a620b00a72719ac03092f Author: Harald Anlauf <anlauf@gmx.de> Date: Wed Nov 17 22:21:24 2021 +0100 Fortran: NULL() is not interoperable gcc/fortran/ChangeLog: PR fortran/101329 * check.c (is_c_interoperable): Reject NULL() as it is not interoperable. gcc/testsuite/ChangeLog: PR fortran/101329 * gfortran.dg/pr101329.f90: New test. Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org> (cherry picked from commit 3535be6c6f440909798d1c78e862a657f7adaf63) Diff: --- gcc/fortran/check.c | 6 ++++++ gcc/testsuite/gfortran.dg/pr101329.f90 | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 1ff6b82aaa9..6341756bf3e 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -5175,6 +5175,12 @@ is_c_interoperable (gfc_expr *expr, const char **msg, bool c_loc, bool c_f_ptr) { *msg = NULL; + if (expr->expr_type == EXPR_NULL) + { + *msg = "NULL() is not interoperable"; + return false; + } + if (expr->ts.type == BT_CLASS) { *msg = "Expression is polymorphic"; diff --git a/gcc/testsuite/gfortran.dg/pr101329.f90 b/gcc/testsuite/gfortran.dg/pr101329.f90 new file mode 100644 index 00000000000..b82210d4e28 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr101329.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! PR fortran/101329 - ICE: Invalid expression in gfc_element_size + +program p + use iso_c_binding + implicit none + integer(c_int), pointer :: ip4 + integer(c_int64_t), pointer :: ip8 + print *, c_sizeof (c_null_ptr) ! valid + print *, c_sizeof (null ()) ! { dg-error "is not interoperable" } + print *, c_sizeof (null (ip4)) ! { dg-error "is not interoperable" } + print *, c_sizeof (null (ip8)) ! { dg-error "is not interoperable" } +end
reply other threads:[~2021-12-27 19:51 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=20211227195109.C5EC13858404@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).