diff mbox series

[committed] Fortran: resolve.c - remove '*XCNEW' based nullifying

Message ID 06938d43-cefc-61cb-aab5-c96c4a626886@codesourcery.com
State New
Headers show
Series [committed] Fortran: resolve.c - remove '*XCNEW' based nullifying | expand

Commit Message

Tobias Burnus June 14, 2021, 12:49 p.m. UTC
Found this odd code. It starts fine with:
   gfc_ref *ref = gfc_get_ref ();
this uses XCNEW to return nullified memory.

We then operate on
where 'ar' is a struct which is in a 'u'nion which is in gfc_ref.

Hence, 'ref->u.ar' is not a pointer. Hence, the following is a
wasteful way to memset '\0' the struct – which is still '\0'
from the first XCNEW:
   ref->u.ar = *gfc_get_array_ref()

Note the '*' before the XCNEW calling macro gfc_get_array_ref!

Committed as obvious.


Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf
diff mbox series


commit a893b26f7311fe65b604f12a8fa5d5d64f5454e2
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Mon Jun 14 14:36:20 2021 +0200

    Fortran: resolve.c - remove '*XCNEW' based nullifying
            * resolve.c (resolve_variable): Remove *XCNEW used to
            nullify nullified memory.

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index a37ad665645..45c3ad387ac 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -5709,7 +5709,6 @@  resolve_variable (gfc_expr *e)
 	     part_ref.  */
 	  gfc_ref *ref = gfc_get_ref ();
 	  ref->type = REF_ARRAY;
-	  ref->u.ar = *gfc_get_array_ref();
 	  ref->u.ar.type = AR_FULL;
 	  if (sym->as)