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


On Sunday 05 April 2009 18:47:50 Steve Kargl wrote:
> > 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)?

No need to. The created variable has the counter tacked on (note the ".4"). A 
variable named "shadow_loopvar" will not interfere as it does not come with 
the counter.


> Can you change the testcase to
>
> ! { dg-do "run" }
> ! PR fortran/29458 - spurious warning for implied do-loop counter
>
>   integer :: n, i
>   n = 5
>   i = 10
>   n = SUM((/(2*i,i=1,n,2)/))
>   if (i /= 10) call abort
> end

Will do. 

Thanks for the review.

	Daniel


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