[patch, fortran] Fix PR29458 - spurious warning for implied do-loop counter
Daniel Franke
franke.daniel@gmail.com
Sun Apr 5 13:17:00 GMT 2009
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:;
}
2009-04-05 Daniel Franke <franke.daniel@gmail.com>
PR fortran/29458
* trans-array.c (gfc_trans_array_constructor_value): Shadow implied
do-loop variable to avoid spurious middle-end warnings.
2009-04-05 Daniel Franke <franke.daniel@gmail.com>
PR fortran/29458
* gfortran.dg/implied_do_1.f90: New.
Regression tested on i686-pc-linux-gnu.
Ok for trunk (and maybe 4.4.1)?
Cheers
Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: implied_do_1.f90
Type: text/x-fortran
Size: 148 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090405/be23fad0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr29458.diff
Type: text/x-patch
Size: 5940 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090405/be23fad0/attachment-0001.bin>
More information about the Fortran
mailing list