From 276515e6adb1c74234908d627d4fee3840046d74 Mon Sep 17 00:00:00 2001
From: Paul Thomas <pault@gcc.gnu.org>
Date: Fri, 1 Dec 2017 15:05:55 +0000
Subject: re PR fortran/82605 ([PDT] ICE in insert_parameter_exprs, at
 fortran/decl.c:3154)

2017-12-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/82605
	* resolve.c (get_pdt_constructor): Initialize 'cons' to NULL.
	(resolve_pdt): Correct typo in prior comment. Emit an error if
	any parameters are deferred and the object is neither pointer
	nor allocatable.

	PR fortran/82606
	* decl.c (gfc_get_pdt_instance): Continue if the parameter sym
	is not present or has no name. Select the parameter by name
	of component, rather than component order. Remove all the other
	manipulations of 'tail' when building the pdt instance.
	(gfc_match_formal_arglist): Emit and error if a star is picked
	up in a PDT decl parameter list.

	PR fortran/82622
	* trans-array.c (set_loop_bounds): If a GFC_SS_COMPONENT has an
	info->end, use it rather than falling through to
	gcc_unreachable.
	(structure_alloc_comps): Check that param->name is non-null
	before comparing with the component name.
	* trans-decl.c (gfc_get_symbol_decl): Do not use the static
	initializer for PDT symbols.
	(gfc_init_default_dt): Do nothing for PDT symbols.
	* trans-io.c (transfer_array_component): Parameterized array
	components use the descriptor ubound since the shape is not
	available.

	PR fortran/82719
	PR fortran/82720
	* trans-expr.c (gfc_conv_component_ref): Do not use the charlen
	backend_decl of pdt strings. Use the hidden component instead.
	* trans-io.c (transfer_expr): Do not do IO on "hidden" string
	lengths. Use the hidden string length for pdt string transfers
	by adding it to the se structure. When finished nullify the
	se string length.

	PR fortran/82866
	* decl.c (gfc_match_formal_arglist): If a name is not found or
	star is found, while reading a type parameter list, emit an
	immediate error.
	(gfc_match_derived_decl): On reading a PDT parameter list, on
	failure to match call gfc_error_recovery.

	PR fortran/82978
	* decl.c (build_struct): Character kind defaults to 1, so use
	kind_expr whatever is the set value.
	(gfc_get_pdt_instance): Ditto.
	* trans-array.c (structure_alloc_comps): Copy the expression
	for the PDT string length before parameter substitution. Use
	this expression for evaluation and free it after use.

2017-12-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/82605
	* gfortran.dg/pdt_4.f03 : Incorporate the new error.

	PR fortran/82606
	* gfortran.dg/pdt_19.f03 : New test.
	* gfortran.dg/pdt_21.f03 : New test.

	PR fortran/82622
	* gfortran.dg/pdt_20.f03 : New test.
	* gfortran.dg/pdt_22.f03 : New test.

	PR fortran/82719
	PR fortran/82720
	* gfortran.dg/pdt_23.f03 : New test.

	PR fortran/82866
	* gfortran.dg/pdt_24.f03 : New test.

	PR fortran/82978
	* gfortran.dg/pdt_10.f03 : Correct for error in coding the for
	kind 4 component and change the kind check appropriately.
	* gfortran.dg/pdt_25.f03 : New test.

From-SVN: r255311
---
 gcc/fortran/trans-decl.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'gcc/fortran/trans-decl.c')

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 3231fb9..ada38b8 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1809,7 +1809,10 @@ gfc_get_symbol_decl (gfc_symbol * sym)
 	  || !gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl))
 	  || sym->attr.data || sym->ns->proc_name->attr.flavor == FL_MODULE)
       && (flag_coarray != GFC_FCOARRAY_LIB
-	  || !sym->attr.codimension || sym->attr.allocatable))
+	  || !sym->attr.codimension || sym->attr.allocatable)
+      && !(sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.pdt_type)
+      && !(sym->ts.type == BT_CLASS
+	   && CLASS_DATA (sym)->ts.u.derived->attr.pdt_type))
     {
       /* Add static initializer. For procedures, it is only needed if
 	 SAVE is specified otherwise they need to be reinitialized
@@ -4004,6 +4007,10 @@ gfc_init_default_dt (gfc_symbol * sym, stmtblock_t * block, bool dealloc)
 
   gcc_assert (block);
 
+  /* Initialization of PDTs is done elsewhere.  */
+  if (sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.pdt_type)
+    return;
+
   gcc_assert (!sym->attr.allocatable);
   gfc_set_sym_referenced (sym);
   e = gfc_lval_expr_from_sym (sym);
-- 
cgit v1.1