diff mbox

[Fortran,cosmetics] Use convenience functions and constants

Message ID 20161122185616.707c470b@vepi2
State New
Headers show

Commit Message

Andre Vehreschild Nov. 22, 2016, 5:56 p.m. UTC
Hi all,

during more hacking on the allocatable components in derived type coarrays, I
encountered the improvable code fragments in the patch attached.

Bootstraps and regtests ok on x86_64-linux/F23. Ok for trunk?

Regards,
	Andre

PS: The patch that motivated these changes follows as soon as its regtesting
has finished.
-- 
Andre Vehreschild * Email: vehre ad gmx dot de

Comments

Steve Kargl Dec. 3, 2016, 5:05 p.m. UTC | #1
On Tue, Nov 22, 2016 at 06:56:16PM +0100, Andre Vehreschild wrote:
> 

> during more hacking on the allocatable components in derived type coarrays, I

> encountered the improvable code fragments in the patch attached.

> 

> Bootstraps and regtests ok on x86_64-linux/F23. Ok for trunk?

> 


OK with a suitable ChangeLog entry.

-- 
Steve
Andre Vehreschild Dec. 3, 2016, 5:25 p.m. UTC | #2
Hi Steve,

Er, thanks for the review and sorry, but I fear I already committed the changes
as part of r243021. These improvables occurred to me while hacking at:

[PATCH, Fortran, accaf, v1] Add caf-API-calls to asynchronously handle
allocatable components in derived type coarrays.
https://gcc.gnu.org/ml/fortran/2016-11/msg00267.html

so they sled in with committing those changes and got a suitable Changelog-entry
while at it.

Thanks again for the review though.

- Andre

On Sat, 3 Dec 2016 09:05:23 -0800
Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:

> On Tue, Nov 22, 2016 at 06:56:16PM +0100, Andre Vehreschild wrote:

> > 

> > during more hacking on the allocatable components in derived type coarrays,

> > I encountered the improvable code fragments in the patch attached.

> > 

> > Bootstraps and regtests ok on x86_64-linux/F23. Ok for trunk?

> >   

> 

> OK with a suitable ChangeLog entry.

> 



-- 
Andre Vehreschild * Email: vehre ad gmx dot de
Steve Kargl Dec. 3, 2016, 6:09 p.m. UTC | #3
On Sat, Dec 03, 2016 at 06:25:19PM +0100, Andre Vehreschild wrote:
> 

> Er, thanks for the review and sorry, but I fear I already committed

> the changes as part of r243021. These improvables occurred to me

> while hacking at:

> 

> [PATCH, Fortran, accaf, v1] Add caf-API-calls to asynchronously handle

> allocatable components in derived type coarrays.

> https://gcc.gnu.org/ml/fortran/2016-11/msg00267.html

> 

> so they sled in with committing those changes and got a suitable

> Changelog-entry

> while at it.

> 

> Thanks again for the review though.

> 


No problem.  I started at the bottom of my mail queue looking
for unreviewed patches.  I did not see one for your patch, so
read through it and found no issues.

-- 
Steve
diff mbox

Patch

diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 1708f7c..45e1369 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -7855,9 +7859,7 @@  duplicate_allocatable (tree dest, tree src, tree type, int rank,

   if (!GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (dest)))
     {
-      tmp = null_pointer_node;
-      tmp = fold_build2_loc (input_location, MODIFY_EXPR, type, dest, tmp);
-      gfc_add_expr_to_block (&block, tmp);
+      gfc_add_modify (&block, dest, fold_convert (type, null_pointer_node));
       null_data = gfc_finish_block (&block);

       gfc_init_block (&block);
@@ -7869,9 +7871,7 @@  duplicate_allocatable (tree dest, tree src, tree type, int rank,
       if (!no_malloc)
        {
          tmp = gfc_call_malloc (&block, type, size);
-         tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node,
-                                dest, fold_convert (type, tmp));
-         gfc_add_expr_to_block (&block, tmp);
+         gfc_add_modify (&block, dest, fold_convert (type, tmp));
        }

       if (!no_memcpy)
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index ba71a21..2e6ef2a 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -5093,8 +5103,8 @@  generate_coarray_sym_init (gfc_symbol *sym)
                             build_int_cst (integer_type_node, reg_type),
                             token, gfc_build_addr_expr (pvoid_type_node, desc),
                             null_pointer_node, /* stat.  */
-                            null_pointer_node, /* errgmsg, errmsg_len.  */
-                            build_int_cst (integer_type_node, 0));
+                            null_pointer_node, /* errgmsg.  */
+                            integer_zero_node); /* errmsg_len.  */
   gfc_add_expr_to_block (&caf_init_block, tmp);
   gfc_add_modify (&caf_init_block, decl, fold_convert (TREE_TYPE (decl),
                                          gfc_conv_descriptor_data_get (desc)));