Hi!

On Thu, May 07, 2020 at 02:45:29PM +0200, Thomas Schwinge wrote:
> >>+      for (tree op = win; TREE_CODE (op) == COMPOUND_EXPR;
> 
> ..., and new 'op' variable here.
> 
> >>+        op = TREE_OPERAND (op, 1))
> >>+     v.safe_push (op);
> >>+      FOR_EACH_VEC_ELT_REVERSE (v, i, op)
> >>+     ret = build2_loc (EXPR_LOCATION (op), COMPOUND_EXPR,
> >>+                       TREE_TYPE (win), TREE_OPERAND (op, 0),
> >>+                       ret);
> >>+      return ret;
> >>     }
> >>   while (TREE_CODE (op) == NOP_EXPR)
> >>     {

There is no reason for the shadowing and op at this point acts as a
temporary and will be overwritten in FOR_EACH_VEC_ELT_REVERSE anyway.
So, we can just s/tree // here.
Ok for trunk if it passes bootstrap/regtest?

> ("Interesting.")  The bootstrapped GCC itself doesn't diagnose this.  Is
> there something to be worried about?  (Certainly the variable shadowing
> could be avoided?)

Nothing to be worried about, -Wshadow isn't part of -W -Wall from what I can
understand.  If you use -Wshadow, it is diagnosed.

2020-05-07  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/94724
        * tree.c (get_narrower): Reuse the op temporary instead of
        shadowing it.

--- gcc/tree.c.jj       2020-05-05 08:57:55.646638787 +0200
+++ gcc/tree.c  2020-05-07 15:58:17.049717054 +0200
@@ -8889,7 +8889,7 @@ get_narrower (tree op, int *unsignedp_pt
        return win;
       auto_vec <tree, 16> v;
       unsigned int i;
-      for (tree op = win; TREE_CODE (op) == COMPOUND_EXPR;
+      for (op = win; TREE_CODE (op) == COMPOUND_EXPR;
           op = TREE_OPERAND (op, 1))
        v.safe_push (op);
       FOR_EACH_VEC_ELT_REVERSE (v, i, op)


        Jakub

Reply via email to