aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Eggleston <markeggleston@gcc.gnu.org>2020-07-27 15:28:50 +0100
committerMark Eggleston <markeggleston@gcc.gnu.org>2020-07-29 12:55:17 +0100
commit6af8284719d151087a1c1e4da210cc5a9fa4a478 (patch)
tree877e0db577ad1ac46478d4cff20c6b6d9e7dfdc2 /gcc
parent2b2f3867c09c8977268b8ffbd646ac242188b335 (diff)
downloadgcc-6af8284719d151087a1c1e4da210cc5a9fa4a478.zip
gcc-6af8284719d151087a1c1e4da210cc5a9fa4a478.tar.gz
gcc-6af8284719d151087a1c1e4da210cc5a9fa4a478.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/intrinsic.c6
-rw-r--r--gcc/testsuite/gfortran.dg/pr96319.f9012
2 files changed, 16 insertions, 2 deletions
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 3518a4e..ef33587 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 0000000..6d8d3b4
--- /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
+