* [PATCH] PR fortran/101329 - ICE: Invalid expression in gfc_element_size
@ 2021-11-17 21:28 Harald Anlauf
2021-11-18 10:51 ` Thomas Koenig
0 siblings, 1 reply; 2+ messages in thread
From: Harald Anlauf @ 2021-11-17 21:28 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 232 bytes --]
Dear Fortranners,
as NULL() is not interoperable, we have to reject it.
Confirmed by NAG. Other compilers show "interesting behavior".
Obvious patch by Steve. Regtested on x86_64-pc-linux-gnu.
OK for mainline?
Thanks,
Harald
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fortran-NULL-is-not-interoperable.patch --]
[-- Type: text/x-patch, Size: 1910 bytes --]
From 52a3ee53f0a12e897c4651fa8378e045653b9fd3 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Wed, 17 Nov 2021 22:21:24 +0100
Subject: [PATCH] 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>
---
gcc/fortran/check.c | 6 ++++++
gcc/testsuite/gfortran.dg/pr101329.f90 | 13 +++++++++++++
2 files changed, 19 insertions(+)
create mode 100644 gcc/testsuite/gfortran.dg/pr101329.f90
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index ffa07b510cd..5a5aca10ebe 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -5223,6 +5223,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
--
2.26.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PR fortran/101329 - ICE: Invalid expression in gfc_element_size
2021-11-17 21:28 [PATCH] PR fortran/101329 - ICE: Invalid expression in gfc_element_size Harald Anlauf
@ 2021-11-18 10:51 ` Thomas Koenig
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2021-11-18 10:51 UTC (permalink / raw)
To: Harald Anlauf, fortran, gcc-patches
On 17.11.21 22:28, Harald Anlauf via Fortran wrote:
> Dear Fortranners,
>
> as NULL() is not interoperable, we have to reject it.
> Confirmed by NAG. Other compilers show "interesting behavior".
>
> Obvious patch by Steve. Regtested on x86_64-pc-linux-gnu.
>
> OK for mainline?
OK, and thanks!
Best regards
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-18 10:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-17 21:28 [PATCH] PR fortran/101329 - ICE: Invalid expression in gfc_element_size Harald Anlauf
2021-11-18 10:51 ` Thomas Koenig
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).