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, fortran] Fix PR29458 - spurious warning for implied do-loop counter


Steve Kargl wrote:
On Sun, Apr 05, 2009 at 03:16:58PM +0200, Daniel Franke wrote:
This code gives a warning about 'i' being used uninitialized:

  integer :: n, i
  n = 5
  n = SUM((/(i,i=1,n)/))
end

Attached patch fixes this by shadowing 'i' with a temporary variable. Further, it wraps the implied-do in its own block instead of placing it in the parent block directly. The relevant part now looks like this, 'i' is never touched:

{ shadow_loopvar.4 = 1;
D.1515 = n;
[...]
while (1)
{
if (shadow_loopvar.4 > D.1515) goto L.1;
(*(integer(kind=4)[0] *) atmp.2.data)[offset.3] = shadow_loopvar.4;
offset.3 = offset.3 + 1;
shadow_loopvar.4 = shadow_loopvar.4 + 1;
}
L.1:;
}

What happens if someone used shadow_loopvar as a variable
in their code? Do we need to use _shadow_loopvar (note the leading underscore)?


I have previously used a % or similar appended to the name that makes it invalid fortran lbel, but valid from the rest of gcc. It was in a patch for run-time error I think, its been a while back.

Jerry


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