diff mbox series

[committed] Fix for PR 91800

Message ID 411a8b42-33f8-4aab-f46f-8172a6e5424c@netcologne.de
State New
Headers show
Series [committed] Fix for PR 91800 | expand

Commit Message

Thomas Koenig April 20, 2020, 11:24 a.m. UTC
Hello world,

I just committed as obvious (alternatively, reviewed and
committed) Steve's patch for PR 91800 from the PR,
after regression-testing.

Regards

	Thomas

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 mbox series

Patch

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)
     {