diff options
-rw-r--r-- | gcc/fortran/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fortran/decl.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/hollerith_9.f90 | 7 |
4 files changed, 29 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 336ce490..2671c1a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2020-04-20 Steve Kargl <kargl@gcc.gnu.org> + Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/91800 + * decl.c (variable_decl): Reject Hollerith constants as type + initializer. + 2020-04-19 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/93500 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index b3ed63c..d650407 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -2904,6 +2904,15 @@ variable_decl (int elem) } if (gfc_current_state () == COMP_DERIVED + && initializer && initializer->ts.type == BT_HOLLERITH) + { + gfc_error ("Initialization of structure component with a HOLLERITH " + "constant at %L is not allowed", &initializer->where); + m = MATCH_ERROR; + goto cleanup; + } + + if (gfc_current_state () == COMP_DERIVED && gfc_current_block ()->attr.pdt_template) { gfc_symbol *param; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 27ab547..f8dba65 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-04-20 Steve Kargl <kargl@gcc.gnu.org> + Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/91800 + * gfortran.dg/hollerith_9.f90: New test. + 2020-04-19 David Edelsohn <dje.gcc@gmail.com> * g++.dg/debug/dwarf2/pr85550.C: Skip AIX. diff --git a/gcc/testsuite/gfortran.dg/hollerith_9.f90 b/gcc/testsuite/gfortran.dg/hollerith_9.f90 new file mode 100644 index 0000000..cfa1620 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/hollerith_9.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR 91800 - this used to cause an ICE. +module m + type t(n) ! { dg-error "does not have a component corresponding to parameter" } + integer, len :: n = 4habcd ! { dg-error "Initialization of structure component with a HOLLERITH constant" } + end type +end |