aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Eggleston <markeggleston@gcc.gnu.org>2020-02-18 14:15:41 +0000
committerMark Eggleston <markeggleston@gcc.gnu.org>2020-02-18 14:15:41 +0000
commit23d3f25c87d307536f7e0f15e211968a87657602 (patch)
treef1a38ab5169c3ccb426df0042d1b9e2b8000a93a /gcc
parent08afe87b7976e93197a66e01f93191ead496ad42 (diff)
downloadgcc-23d3f25c87d307536f7e0f15e211968a87657602.zip
gcc-23d3f25c87d307536f7e0f15e211968a87657602.tar.gz
gcc-23d3f25c87d307536f7e0f15e211968a87657602.tar.bz2
[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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/match.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr93601.f907
4 files changed, 28 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 2e874b8..5daaefd 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,11 @@
2020-02-18 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.
+
+2020-02-18 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
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 9c2ec41..e4d5224 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/ChangeLog b/gcc/testsuite/ChangeLog
index 9f7a4f7..6b008fd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-18 Mark Eggleston <mark.eggleston@codethink.com>
+
+ PR fortran/93601
+ * gfortran.dg/pr93601.f90 : New test.
+
2020-02-18 Martin Liska <mliska@suse.cz>
PR ipa/93583
diff --git a/gcc/testsuite/gfortran.dg/pr93601.f90 b/gcc/testsuite/gfortran.dg/pr93601.f90
new file mode 100644
index 0000000..495447c
--- /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
+