[gcc/devel/ranger] PR 91800 - reject Hollerith constants as type initializer.
Aldy Hernandez
aldyh@gcc.gnu.org
Wed Jun 17 20:33:03 GMT 2020
https://gcc.gnu.org/g:38acc41d6d761b635123eefa93743b9139debbae
commit 38acc41d6d761b635123eefa93743b9139debbae
Author: Steve Kargl <kargl@gcc.gnu.org>
Date: Mon Apr 20 13:21:38 2020 +0200
PR 91800 - reject Hollerith constants as type initializer.
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-20 Steve Kargl <kargl@gcc.gnu.org>
Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/91800
* gfortran.dg/hollerith_9.f90: New test.
Diff:
---
gcc/fortran/ChangeLog | 7 +++++++
gcc/fortran/decl.c | 9 +++++++++
gcc/testsuite/ChangeLog | 6 ++++++
gcc/testsuite/gfortran.dg/hollerith_9.f90 | 7 +++++++
4 files changed, 29 insertions(+)
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 336ce49090e..2671c1aa381 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 b3ed63c97cc..d650407da41 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -2903,6 +2903,15 @@ variable_decl (int elem)
goto cleanup;
}
+ 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)
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 27ab5478d29..f8dba65ff9f 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 00000000000..cfa16209e93
--- /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
More information about the Gcc-cvs
mailing list