[committed] PR fortran/103412 - [10/11/12 Regression] ICE: Invalid expression in gfc_element_size since r10-2083-g8dc63166e0b85954
Commit Message
Dear all,
committed as obvious after discussion with Steve: SIZEOF() cannot
accept a BOZ argument which has no defined type.
Regtested on x86_64-pc-linux-gnu.
Thanks,
Harald
From fd74a2ee40456a1d1621e88738f8e57536194080 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Sat, 18 Dec 2021 23:21:35 +0100
Subject: [PATCH] Fortran: reject BOZ type argument to SIZEOF().
gcc/fortran/ChangeLog:
PR fortran/103412
* check.c (gfc_check_sizeof): Reject BOZ type argument.
gcc/testsuite/ChangeLog:
PR fortran/103412
* gfortran.dg/illegal_boz_arg_2.f90: New test.
---
gcc/fortran/check.c | 3 +++
gcc/testsuite/gfortran.dg/illegal_boz_arg_2.f90 | 6 ++++++
2 files changed, 9 insertions(+)
create mode 100644 gcc/testsuite/gfortran.dg/illegal_boz_arg_2.f90
@@ -5135,6 +5135,9 @@ gfc_check_sizeof (gfc_expr *arg)
return false;
}
+ if (illegal_boz_arg (arg))
+ return false;
+
/* TYPE(*) is acceptable if and only if it uses an array descriptor. */
if (arg->ts.type == BT_ASSUMED
&& (arg->symtree->n.sym->as == NULL
new file mode 100644
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! PR fortran/103412
+
+program p
+ integer, parameter :: a = sizeof(z'1') ! { dg-error "cannot be an actual" }
+end
--
2.26.2