This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, fortran] PR 47359 - warnings for constant conversion
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 01 Jun 2015 08:34:24 +0200
- Subject: Re: [patch, fortran] PR 47359 - warnings for constant conversion
- Authentication-results: sourceware.org; auth=none
- References: <556B7ED1 dot 4020304 at netcologne dot de> <20150531221425 dot GA34602 at troutmask dot apl dot washington dot edu>
Hi Steve,
>> The second part catches the case when the user supplies more
>> digits than appropriate for the number. More often than not,
>> this is a KIND error.
>>
>
> Does the above issue warnings for
>
> real(knd), parameter :: pi = 3.1415926535897932384626433832795029_knd
>
> module foomod
>
> interface foo
> module procedure foo4, foo8, foo10, foo16
> end interface foo
>
> contains
>
> subroutine foo4()
> integer, parameter :: knd = 4
> include 'consts.def'
> ! do something with pi
> end subroutine
> end module foomod
Yes, it does, if -Wconversion-extra is specified.
> If warnings occur, then IMHO the patch cannot be committed
> in its current form.
What would be the peferred alternative?
I can make this warning conditional on a new option, let's call it
-Wconversion-constant, and have this set by default by -Wsurprising
or by -Wconversion. The new options machinery is nice enough to
specify the option name with the warning, so it is easy for a user
to turn this particular warning off.
It would also be possible to grade this warning for really fine-grained
control:
- Introduce -Wconversion-constant, enabled by -Wconversion, to warn
about the most common error of a constant with excess precision
without KIND, so print *,3.1415829535 would get a warning and
print *,3.1415926535_4 would not.
- Introduce -Wconversion-constant-extra, enabled by -Wconversion-extra,
to warn about any excess precision regardless whether a KIND number
is present in the constant or not.
Comments?
Thomas