From 8f55a0eec910dd02992f4caca083048d91c0b2e1 Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Tue, 18 Feb 2020 12:23:20 +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 . 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/ChangeLog | 7 +++++++ gcc/fortran/match.c | 8 ++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr93603.f90 | 7 +++++++ 4 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr93603.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 302af3a..2e874b8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,4 +1,11 @@ 2020-02-18 Steven G. Kargl + + PR fortran/93603 + * match.c (gfc_match_associate) : If target expression + has the type BT_BOZ output an error and goto + assocListError. + +2020-02-18 Steven G. Kargl Mark Eggleston PR fortran/93580 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index a74cb8c..9c2ec41 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/ChangeLog b/gcc/testsuite/ChangeLog index 1c7f879..f9a545e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-02-18 Mark Eggleston + + PR fortran/93603 + * gfortran.dg/pr93603.f90 : New test. + 2020-02-20 Mark Eggleston PR fortran/93580 diff --git a/gcc/testsuite/gfortran.dg/pr93603.f90 b/gcc/testsuite/gfortran.dg/pr93603.f90 new file mode 100644 index 0000000..fd452e5 --- /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.7.4