This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix a recent warning in reorg.c


On 04/26/2016 07:08 AM, Jakub Jelinek wrote:
Hi!

I've noticed a warning during bootstrap:
../../gcc/reorg.c: In function âvoid try_merge_delay_insns(rtx_insn*, rtx_insn*)â:
../../gcc/reorg.c:1431:12: warning: name lookup of âiâ changed
       for (i = 0; i < XVECLEN (PATTERN (insn), 0); i++)
            ^
../../gcc/reorg.c:1263:7: warning:   matches this âiâ under ISO standard rules
   int i, j;
       ^
../../gcc/reorg.c:1413:25: warning:   matches this âiâ under old rules
       for (unsigned int i = len - 1; i < len; i--)
                         ^
It is not fatal, but still ugly.  The problem is that the function has
  int i;
...
  for (i = 0; ...)
...
  for (unsigned int i = ... )
...
  for (i = 0; ...)
This patch just declares the var in the only affected loop, so that the warning
is not emitted, unless we start checking -Wshadow warnings, I think this is
good enough.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-04-26  Jakub Jelinek  <jakub@redhat.com>

	* reorg.c (try_merge_delay_insns): Declare i inside the last
	for loop to avoid warning.
I'd like to declare this in the "obviously OK" category for future changes of a similar nature. But I don't think we can because in the general case the value from the loop may be used outside the loop.

Makes me wonder if a plugin could help identify the obvious cases where the value from the loop isn't used outside the loop, thus allowing someone to quickly convert many of these things with a small effort.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]