Please find attached patch for PR96319.
LOGICAL values fit regardless of kind so warnings are unnecessary. The
PR referred to the warning produced for -Wconversion. This patch also
suppresses the warning for -Wconversion-extra.
-Wconversion produces
"Possible change of value in conversion from LOGICAL(4) to LOGICAL(1) ..."
-Wconversion-extra produces
"Conversion from LOGICAL(4) to LOGICAL(1) ..."
Should both warnings be suppressed or just the warning in the original PR?
Note: both messages are missing when -Wconversion -Wconversion-extra are
used with the gfortran-9 branch.
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-28 Mark Eggleston <markeggles...@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-28 Mark Eggleston <markeggles...@gcc.gnu.org>
gcc/testsuite/
PR fortran/96319
* gfortran.dg/pr96319.f90: New test.
--
https://www.codethink.co.uk/privacy.html
>From a2d447bc8986a1881348adb5f115e6f5107d6582 Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggles...@gcc.gnu.org>
Date: Mon, 27 Jul 2020 15:28:50 +0100
Subject: [PATCH] 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-28 Mark Eggleston <markeggles...@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-28 Mark Eggleston <markeggles...@gcc.gnu.org>
gcc/testsuite/
PR fortran/96319
* gfortran.dg/pr96319.f90: New test.
---
gcc/fortran/intrinsic.c | 6 ++++--
gcc/testsuite/gfortran.dg/pr96319.f90 | 12 ++++++++++++
2 files changed, 16 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gfortran.dg/pr96319.f90
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 3518a4e2c87..ef33587a774 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -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 "
diff --git a/gcc/testsuite/gfortran.dg/pr96319.f90 b/gcc/testsuite/gfortran.dg/pr96319.f90
new file mode 100644
index 00000000000..6d8d3b476eb
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr96319.f90
@@ -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
+
--
2.11.0