public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][Fortran] Properly generate DECL_EXPRs for temporary arrays
@ 2016-04-29  9:07 Richard Biener
  2016-04-29 17:03 ` Jerry DeLisle
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2016-04-29  9:07 UTC (permalink / raw)
  To: gcc-patches, fortran


The following makes sure to create DECL_EXPRs for VLA types built for
temporary arrays to properly allow the gimplifier to unshare expression
in its type fields when required.

This avoids turing those fields into garbage.  With a patch to allow
the gimplifier to introduce SSA names it avoids ICEs for

gfortran.dg/auto_char_pointer_array_result_1.f90
gfortran.dg/interface_12.f90
gfortran.dg/result_in_spec_1.f90

and

libgomp.fortran/vla7.f90

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for trunk?

I'm not sure testsuite coverage catched all cases this was missing so
other places might need similar handling after the SSA patch goes
in and this gets applied to the real world (TM).

Thanks,
Richard.

2016-04-29  Richard Biener  <rguenther@suse.de>

	fortran/
	* trans-array.c (gfc_trans_create_temp_array): Properly
	create a DECL_EXPR for the anonymous VLA array type.

Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c.orig	2016-04-28 14:11:00.064581449 +0200
--- gcc/fortran/trans-array.c	2016-04-28 14:11:08.120671151 +0200
*************** gfc_trans_create_temp_array (stmtblock_t
*** 1094,1099 ****
--- 1094,1109 ----
    info->descriptor = desc;
    size = gfc_index_one_node;
  
+   /* Emit a DECL_EXPR for the variable sized array type in
+      GFC_TYPE_ARRAY_DATAPTR_TYPE so the gimplification of its type
+      sizes works correctly.  */
+   tree arraytype = TREE_TYPE (GFC_TYPE_ARRAY_DATAPTR_TYPE (type));
+   if (! TYPE_NAME (arraytype))
+     TYPE_NAME (arraytype) = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
+ 					NULL_TREE, arraytype);
+   gfc_add_expr_to_block (pre, build1 (DECL_EXPR,
+ 				      arraytype, TYPE_NAME (arraytype)));
+ 
    /* Fill in the array dtype.  */
    tmp = gfc_conv_descriptor_dtype (desc);
    gfc_add_modify (pre, tmp, gfc_get_dtype (TREE_TYPE (desc)));

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][Fortran] Properly generate DECL_EXPRs for temporary arrays
  2016-04-29  9:07 [PATCH][Fortran] Properly generate DECL_EXPRs for temporary arrays Richard Biener
@ 2016-04-29 17:03 ` Jerry DeLisle
  0 siblings, 0 replies; 2+ messages in thread
From: Jerry DeLisle @ 2016-04-29 17:03 UTC (permalink / raw)
  To: Richard Biener, gcc-patches, fortran

On 04/29/2016 02:06 AM, Richard Biener wrote:
> 
> The following makes sure to create DECL_EXPRs for VLA types built for
> temporary arrays to properly allow the gimplifier to unshare expression
> in its type fields when required.
> 
> This avoids turing those fields into garbage.  With a patch to allow
> the gimplifier to introduce SSA names it avoids ICEs for
> 
> gfortran.dg/auto_char_pointer_array_result_1.f90
> gfortran.dg/interface_12.f90
> gfortran.dg/result_in_spec_1.f90
> 
> and
> 
> libgomp.fortran/vla7.f90
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
> 
> Ok for trunk?
> 
OK and thanks.

Jerry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-29 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29  9:07 [PATCH][Fortran] Properly generate DECL_EXPRs for temporary arrays Richard Biener
2016-04-29 17:03 ` Jerry DeLisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).