[Regression,Fortran] ICE in gfc_typenode_for_spec PR93603

Message ID 9a0ae9c5-9f81-45ac-e43c-0a80c4d4f04b@codethink.co.uk
State New
Headers show
Series
  • [Regression,Fortran] ICE in gfc_typenode_for_spec PR93603
Related show

Commit Message

Mark Eggleston Feb. 17, 2020, 1:17 p.m.
Please find attached fix for PR fortran/93603.

gcc/fortran/ChangeLog

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

     PR fortran/93603
     * match.c (gfc_match_associate) : If target expression
     has the type BT_BOZ output an error and goto
     assocListError.

gcc/testsuite/ChangeLog

     Mark Eggleston  <mark.eggleston@codethink.com>

     PR fortran/93603
     * gfortran.dg/pr93603.f90 : New test.

Tested using make with check-fortran on master at:

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

OK to commit?

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

Comments

Thomas Koenig Feb. 17, 2020, 10:05 p.m. | #1
Hi Mark and Steve,

> OK to commit?


OK (bordering on obvious).

Thanks to both of you!

Regards

	Thomas

Patch

From 42e66ff8910e995e6b8fb9bb597a09ec7be07def Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggleston@gcc.gnu.org>
Date: Fri, 7 Feb 2020 11:39:37 +0000
Subject: [PATCH] [Fortran] ICE in gfc_typenode_for_spec PR93603

Associating a symbol with a BOZ constant caused an ICE.  Output
an error message as an association target cannot be a BOZ
constant.

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

gcc/fortran/ChangeLog

	PR fortran/93603
	* match.c (gfc_match_associate) : If target expression
	has the type BT_BOZ output an error and goto
	assocListError.

gcc/testsuite/ChangeLog

	PR fortran/93603
	* gfortran.dg/pr93603.f90 : New test.
---
 gcc/fortran/match.c                   | 8 ++++++++
 gcc/testsuite/gfortran.dg/pr93603.f90 | 7 +++++++
 2 files changed, 15 insertions(+)
 create mode 100644 gcc/testsuite/gfortran.dg/pr93603.f90

diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index a74cb8c5c19..9c2ec41c49c 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -1957,6 +1957,14 @@  gfc_match_associate (void)
 	  goto assocListError;
 	}
 
+      /* The target expression cannot be a BOZ literal constant.  */
+      if (newAssoc->target->ts.type == BT_BOZ)
+	{
+	  gfc_error ("Association target at %L cannot be a BOZ literal "
+		     "constant", &newAssoc->target->where);
+	  goto assocListError;
+	}
+
       /* The `variable' field is left blank for now; because the target is not
 	 yet resolved, we can't use gfc_has_vector_subscript to determine it
 	 for now.  This is set during resolution.  */
diff --git a/gcc/testsuite/gfortran.dg/pr93603.f90 b/gcc/testsuite/gfortran.dg/pr93603.f90
new file mode 100644
index 00000000000..fd452e52ca2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93603.f90
@@ -0,0 +1,7 @@ 
+! { dg-do compile }
+
+program p
+  associate (y => z'1') ! { dg-error "cannot be a BOZ literal constant" }
+  end associate         ! { dg-error "Expecting END PROGRAM" }
+end
+
-- 
2.11.0