public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR 82018: -Wextra should imply -Wconversion-extra
@ 2017-09-16 17:21 Janus Weil
  2017-09-17 21:18 ` Thomas Koenig
  2017-09-18  9:40 ` Janus Weil
  0 siblings, 2 replies; 8+ messages in thread
From: Janus Weil @ 2017-09-16 17:21 UTC (permalink / raw)
  To: gfortran, gcc-patches, Thomas Koenig

[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]

Hi all,

here is a small patch that enables -Wconversion-extra with -Wextra and
updates the documentation.

Up to gfortran 5, the warning in the test case was enabled by
-Wconversion, and thus with -Wall. That was changed by Thomas in
r224190, which makes complete sense to me.

However, I think -Wconversion-extra should be implied by -Wextra (I'm
sure not everyone wants to see such messages, but I think they're
still useful).

The patch regtests cleanly on x86_64-linux-gnu. Ok for trunk?

As a sidenote, I made an observation that is not directly related to
the patch: The second warning in the test case, on "i4 = i8" shows
[-Wconversion] when compiled with -Wall, but [-Wconversion-extra] when
compiled with -Wextra. Does anyone understand how that inconsistency
comes about?

Cheers,
Janus



2017-09-16  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/82018
    * lang.opt: Turn on -Wconversion-extra with -Wextra.
    * invoke.texi: Update documentation of -Wconversion-extra and -Wextra
    and mention both in the list of Error and Warning Options.

2017-09-16  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/82018
    * gfortran.dg/wextra_2.f90: New test case.

[-- Attachment #2: pr82018.diff --]
[-- Type: text/plain, Size: 2502 bytes --]

Index: gcc/fortran/invoke.texi
===================================================================
--- gcc/fortran/invoke.texi	(revision 252872)
+++ gcc/fortran/invoke.texi	(working copy)
@@ -144,10 +144,10 @@ by type.  Explanations are in the following sectio
 @item Error and Warning Options
 @xref{Error and Warning Options,,Options to request or suppress errors
 and warnings}.
-@gccoptlist{-Waliasing -Wall -Wampersand -Wargument-mismatch -Warray-bounds
--Wc-binding-type -Wcharacter-truncation @gol
--Wconversion -Wfunction-elimination -Wimplicit-interface @gol
--Wimplicit-procedure -Wintrinsic-shadow -Wuse-without-only -Wintrinsics-std @gol
+@gccoptlist{-Waliasing -Wall -Wampersand -Wargument-mismatch -Warray-bounds @gol
+-Wc-binding-type -Wcharacter-truncation -Wconversion -Wconversion-extra @gol
+-Wextra -Wfunction-elimination -Wimplicit-interface -Wimplicit-procedure @gol
+-Wintrinsic-shadow -Wuse-without-only -Wintrinsics-std @gol
 -Wline-truncation -Wno-align-commons -Wno-tabs -Wreal-q-constant @gol
 -Wsurprising -Wunderflow -Wunused-parameter -Wrealloc-lhs -Wrealloc-lhs-all @gol
 -Wtarget-lifetime -fmax-errors=@var{n} -fsyntax-only -pedantic -pedantic-errors
@@ -884,7 +884,7 @@ the expression after conversion. Implied by @optio
 @cindex warnings, conversion
 @cindex conversion
 Warn about implicit conversions between different types and kinds. This
-option does @emph{not} imply @option{-Wconversion}.
+option does @emph{not} imply @option{-Wconversion}. Implied by @option{-Wextra}.
 
 @item -Wextra
 @opindex @code{Wextra}
@@ -891,8 +891,8 @@ Warn about implicit conversions between different
 @cindex extra warnings
 @cindex warnings, extra
 Enables some warning options for usages of language features which
-may be problematic. This currently includes @option{-Wcompare-reals}
-and @option{-Wunused-parameter}.
+may be problematic. This currently includes @option{-Wcompare-reals},
+@option{-Wunused-parameter} and @option{-Wconversion-extra}.
 
 @item -Wimplicit-interface
 @opindex @code{Wimplicit-interface}
Index: gcc/fortran/lang.opt
===================================================================
--- gcc/fortran/lang.opt	(revision 252872)
+++ gcc/fortran/lang.opt	(working copy)
@@ -234,7 +234,7 @@ Fortran Var(warn_conversion) Warning LangEnabledBy
 ; Documented in C
 
 Wconversion-extra
-Fortran Var(warn_conversion_extra) Warning
+Fortran Var(warn_conversion_extra) Warning LangEnabledBy(Fortran,Wextra)
 Warn about most implicit conversions.
 
 Wextra

[-- Attachment #3: wextra_2.f90 --]
[-- Type: text/x-fortran, Size: 330 bytes --]

! { dg-do compile }
! { dg-options "-Wall -Wextra" }
!
! PR 82018: -Wextra should imply -Wconversion-extra
!
! Contributed by Janus Weil <janus@gcc.gnu.org>

implicit none
integer(kind=4) :: i4
integer(kind=8) :: i8
i8 = 2.0   ! { dg-warning "Conversion" }
i4 = i8    ! { dg-warning "Possible change of value in conversion" }
end

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [Patch, Fortran] PR 82018: -Wextra should imply -Wconversion-extra
@ 2017-09-18  9:50 Dominique d'Humières
  2017-09-19 19:59 ` Thomas Koenig
  0 siblings, 1 reply; 8+ messages in thread
From: Dominique d'Humières @ 2017-09-18  9:50 UTC (permalink / raw)
  To: Janus Weil; +Cc: Thomas Koenig, gfortran, gcc-patches

As said in bugzilla, I am against this change. If you want to use -Wconversion-extra, just add it to your favorite options.

-Wconversion-extra is extremely noisy and -Wextra has been stable for some years. IMO we cannot afford to have people complaining about the change.

If you really want a synthetic option, why not a new one -Wnoisy (or -Weally-all, …) which implies '-Wall -Wextra  -Wconversion-extra …’?

Dominique

PS. Who wants

Warning: Conversion from 'REAL(4)' to 'REAL(8)' at (1) [-Wconversion-extra]

even if may allow to detect things such as ‘pi8=acos(-1.0)’?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-09-19 21:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-16 17:21 [Patch, Fortran] PR 82018: -Wextra should imply -Wconversion-extra Janus Weil
2017-09-17 21:18 ` Thomas Koenig
2017-09-18  9:31   ` Janus Weil
2017-09-18  9:40 ` Janus Weil
2017-09-18  9:50 Dominique d'Humières
2017-09-19 19:59 ` Thomas Koenig
2017-09-19 20:26   ` Dominique d'Humières
2017-09-19 21:37     ` Steve Kargl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).