public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: fortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH, committed] PR fortran/103412 - [10/11/12 Regression] ICE: Invalid expression in gfc_element_size since r10-2083-g8dc63166e0b85954
Date: Sat, 18 Dec 2021 23:25:51 +0100	[thread overview]
Message-ID: <trinity-439f2b20-e5fa-42b0-b0c6-4f8c0e32510e-1639866351229@3c-app-gmx-bap25> (raw)

[-- Attachment #1: Type: text/plain, Size: 178 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fortran-reject-BOZ-type-argument-to-SIZEOF.patch --]
[-- Type: text/x-patch, Size: 1507 bytes --]

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

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 3934336df2e..625473c90d1 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/illegal_boz_arg_2.f90 b/gcc/testsuite/gfortran.dg/illegal_boz_arg_2.f90
new file mode 100644
index 00000000000..3e5f6b6d1d4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/illegal_boz_arg_2.f90
@@ -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


                 reply	other threads:[~2021-12-18 22:25 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=trinity-439f2b20-e5fa-42b0-b0c6-4f8c0e32510e-1639866351229@3c-app-gmx-bap25 \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@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: link
Be 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).