public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Regression, patch][Fortran] ICE: Invalid expression in gfc_element_size PR93601
@ 2020-02-17 14:07 Mark Eggleston
  2020-02-17 22:06 ` Thomas Koenig
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Eggleston @ 2020-02-17 14:07 UTC (permalink / raw)
  To: gcc-patches, fortran

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

Please find attached a fix for PR93601.

gcc/fortran/ChangeLogs

     Steven G. Kargl  <kargl@gcc.gnu.org>

     PR fortran/93601
     * match.c (gfc_match_assignment) : Reject assignment if
     the lhs stype is BT_CLASS and the rhs type is BT_BOZ.

gcc/testsuite/ChangeLogs

     Mark Eggleston  <mark.eggleston@codethink.com>

     PR fortran/93601
     * gfortran.dg/pr93601.f90 : New test.

Test using make with check-fortran on master at

https://gcc.gnu.org/g:f82617f229b336d856c18313339b14657e05c129

OK to commit?

-- 
https://www.codethink.co.uk/privacy.html


[-- Attachment #2: 0001-Fortran-ICE-Invalid-expression-in-gfc_element_size-P.patch --]
[-- Type: text/x-patch, Size: 1957 bytes --]

From d5e4dab84324f3c31eeaf3bf22dd96503d34e654 Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggleston@gcc.gnu.org>
Date: Fri, 7 Feb 2020 15:33:38 +0000
Subject: [PATCH] [Fortran] ICE: Invalid expression in gfc_element_size PR93601

ICE occurs when assigning a BOZ constant to an class(*) variable
with the allocatable attribute. Use of BOZ constants outside
data statements and int/real/dble/cmplx intrinsics is not allowed.

Original patch provided by Steven G. Kargl  <kargl@gcc.gnu.org>.

gcc/fortran/ChangeLog

	PR fortran/93601
	* match.c (gfc_match_assignment) : Reject assignment if
	the lhs stype is BT_CLASS and the rhs type is BT_BOZ.

gcc/testsuite/ChangeLog

	PR fortran/93601
	* gfortran.dg/pr93601.f90 : New test.
---
 gcc/fortran/match.c                   | 10 ++++++++++
 gcc/testsuite/gfortran.dg/pr93601.f90 |  7 +++++++
 2 files changed, 17 insertions(+)
 create mode 100644 gcc/testsuite/gfortran.dg/pr93601.f90

diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index a74cb8c5c19..5713dc20180 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -1348,6 +1348,16 @@ gfc_match_assignment (void)
   rvalue = NULL;
   m = gfc_match (" %e%t", &rvalue);
 
+  if (m == MATCH_YES
+      && rvalue->ts.type == BT_BOZ
+      && lvalue->ts.type == BT_CLASS)
+    {
+      m = MATCH_ERROR;
+      gfc_error ("BOZ literal constant at %L is neither a DATA statement "
+		 "value nor an actual argument of INT/REAL/DBLE/CMPLX "
+		 "intrinsic subprogram", &rvalue->where);
+    }
+
   if (lvalue->expr_type == EXPR_CONSTANT)
     {
       /* This clobbers %len and %kind.  */
diff --git a/gcc/testsuite/gfortran.dg/pr93601.f90 b/gcc/testsuite/gfortran.dg/pr93601.f90
new file mode 100644
index 00000000000..495447c637b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93601.f90
@@ -0,0 +1,7 @@
+! { dg-do compile }
+
+program p
+   class(*), allocatable :: z
+   z = z'1' ! { dg-error "BOZ literal constant at" }
+end
+
-- 
2.11.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Regression, patch][Fortran] ICE: Invalid expression in gfc_element_size PR93601
  2020-02-17 14:07 [Regression, patch][Fortran] ICE: Invalid expression in gfc_element_size PR93601 Mark Eggleston
@ 2020-02-17 22:06 ` Thomas Koenig
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2020-02-17 22:06 UTC (permalink / raw)
  To: Mark Eggleston, gcc-patches, fortran

Hi Mark and Steve,

> OK to commit?

Yes. Again, thanks a lot!

Regards

	Thomas


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-17 22:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 14:07 [Regression, patch][Fortran] ICE: Invalid expression in gfc_element_size PR93601 Mark Eggleston
2020-02-17 22:06 ` 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).