This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions
On Tue, Jul 17, 2018 at 10:32 AM Janus Weil <janus@gcc.gnu.org> wrote:
>
> 2018-07-17 9:52 GMT+02:00 Janus Weil <janus@gcc.gnu.org>:
> >> 2018-07-16 21:50 GMT+02:00 Thomas Koenig <tkoenig@netcologne.de>:
> >>> What I would suggest is to enable -Wfunction-eliminiation with
> >>> -Wextra and also use that for your new warning.
> >>
> >> Thanks for the comments. Makes sense. Updated patch attached.
> >
> >
> > Huh, after actually trying -Wfunction-elimination, I'm not so sure any
> > more if it really makes sense to throw the new warnings in there,
> > mainly for two reasons:
[...]
> > In other words: Does it make sense to tone down
> > -Wfunction-elimination, by only warning about impure functions?
>
> Here is an update of the patch which does that. Regtesting now ...
>
> Cheers,
> Janus
Would not this break the testcase function_optimize_5.f90 :
write (unit=line, fmt='(4F7.2)') matmul(a,b) & ! { dg-warning
"Removing call to function 'matmul'" }
& + matmul(a,b)
z = sin(x) + 2.0 + sin(x) ! { dg-warning "Removing call to function 'sin'" }
print *,z
x = ext_func(a) + 23 + ext_func(a)
print *,d,x
z = element(x) + element(x) ! { dg-warning "Removing call to
function 'element'" }
print *,z
i = mypure(x) - mypure(x) ! { dg-warning "Removing call to function
'mypure'" }
The docs for -Wfunction-elimination would read:
> Warn if any calls to functions are eliminated by the optimizations
> enabled by the @option{-ffrontend-optimize} option.
> This option is implied by @option{-Wextra}.
However, with your patch, it should probably read something like "warn
if any calls to impure functions are eliminated..." Possibly with an
explicit remark indicating that pure functions are not warned.
Additionally:
$ ./contrib/check_GNU_style.sh pr85599_v6.diff
Lines should not exceed 80 characters.
33:+ if (e->expr_type == EXPR_FUNCTION && !gfc_pure_function (e,
&name) && !gfc_implicit_pure_function (e))
36:+ gfc_warning (OPT_Wfunction_elimination, "Removing call to
impure function %qs at %L", name, &(e->where));
38:+ gfc_warning (OPT_Wfunction_elimination, "Removing call to
impure function at %L", &(e->where));
201:+ if (f != last && !gfc_pure_function (f, &name) &&
!gfc_implicit_pure_function (f))
Blocks of 8 spaces should be replaced with tabs.
36:+ gfc_warning (OPT_Wfunction_elimination, "Removing call to
impure function %qs at %L", name, &(e->where));
38:+ gfc_warning (OPT_Wfunction_elimination, "Removing call to
impure function at %L", &(e->where));
230:+ with impure function as second operand. */
Dot, space, space, new sentence.
79:+expression, if they do not contribute to the final result. For logical
82:+result of the expression can be established without them. However, since not
Have you considered using levels for the flag, such that the original
behavior of -Wfunction-elimination would be retained with e.g.
-Wfunction-elimination=2 whereas one could use
-Wfunction-elimination=1 (or similar) to omit warnings about impure
functions?
- Fritz
- References:
- [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions
- Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions
- Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions
- Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions
- Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions
- Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions
- Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions
- Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions
- Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions
- Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions