Fortran : Don't warn for LOGICAL kind conversion PR96319

LOGICAL values will always fit regardless of kind so there
is no need for warnings.

2020-07-29  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/fortran/

	PR fortran/96319
	* intrinsic.c (gfc_convert_type_warn):  Add check for
	LOGICAL type so that warnings are not output.

2020-07-29  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/

	PR fortran/96319
	* gfortran.dg/pr96319.f90: New test.
This commit is contained in:
Mark Eggleston 2020-07-27 15:28:50 +01:00
parent 2b2f3867c0
commit 6af8284719
2 changed files with 16 additions and 2 deletions

View File

@ -5245,8 +5245,10 @@ gfc_convert_type_warn (gfc_expr *expr, gfc_typespec *ts, int eflag, int wflag,
{
/* Larger kinds can hold values of smaller kinds without problems.
Hence, only warn if target kind is smaller than the source
kind - or if -Wconversion-extra is specified. */
if (expr->expr_type != EXPR_CONSTANT)
kind - or if -Wconversion-extra is specified. LOGICAL values
will always fit regardless of kind so ignore conversion. */
if (expr->expr_type != EXPR_CONSTANT
&& ts->type != BT_LOGICAL)
{
if (warn_conversion && from_ts.kind > ts->kind)
gfc_warning_now (OPT_Wconversion, "Possible change of value in "

View File

@ -0,0 +1,12 @@
! { dg-do compile }
! { dg-options "-Wconversion -Wconversion-extra" }
program test
LOGICAL(1) :: a
logical(4) :: t = .true.
logical(4) :: b
logical(1) :: f = .false.
a = t
b = f
end program test