===================================================================
@@ -1,3 +1,10 @@
+2016-04-04 Andre Vehreschild <vehre@gmx.de>
+
+ PR fortran/66911
+ * trans-stmt.c (gfc_trans_allocate): Get the deferred length of an
+ expression by converting the expression when the length is not set
+ in the symbol's ts.
+
2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/65795
===================================================================
@@ -5536,14 +5536,23 @@
if (expr3_len == NULL_TREE
&& code->expr3->ts.type == BT_CHARACTER)
{
+ gfc_init_se (&se, NULL);
if (code->expr3->ts.u.cl
&& code->expr3->ts.u.cl->length)
{
- gfc_init_se (&se, NULL);
gfc_conv_expr (&se, code->expr3->ts.u.cl->length);
gfc_add_block_to_block (&block, &se.pre);
expr3_len = gfc_evaluate_now (se.expr, &block);
}
+ else
+ {
+ /* The string_length is not set in the symbol, which prevents
+ it being set in the ts. Deduce it by converting expr3. */
+ gfc_conv_expr (&se, code->expr3);
+ gfc_add_block_to_block (&block, &se.pre);
+ gcc_assert (se.string_length);
+ expr3_len = gfc_evaluate_now (se.string_length, &block);
+ }
gcc_assert (expr3_len);
}
/* For character arrays only the kind's size is needed, because
===================================================================
@@ -1,3 +1,8 @@
+2016-04-04 Andre Vehreschild <vehre@gmx.de>
+
+ PR fortran/66911
+ * gfortran.dg/deferred_character_16.f90: New test.
+
2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/65795
===================================================================
@@ -0,0 +1,24 @@
+! { dg-do run }
+
+program truc
+implicit none
+
+type t_env_table
+ character(len=:), allocatable :: key
+end type
+
+type(t_env_table), dimension(:), allocatable :: environment_table
+
+character(len=:), allocatable :: s
+
+allocate(environment_table(1))
+environment_table(1)%key='tt'
+
+allocate(s, source=environment_table(1)%key)
+
+if ( .not. allocated(s) ) call abort()
+if ( s /= "tt" ) call abort()
+if ( len(s) /= 2 ) call abort()
+!print *, 's:"', s, '" derived:"',environment_table(1)%key,'"'
+
+end program