From 18bb8b8a2a67091517d60b7192e454ed11e9280d Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sun, 6 Nov 2016 12:27:51 +0000 Subject: [PATCH] re PR fortran/78221 (bogus warning: Non-zero imaginary part discarded in conversion [-Wconversion]) 2016-11-06 Thomas Koenig PR fortran/78221 * arith.c (gfc_complex2real): Change gfc_warning_now to gfc_warning. 2016-11-06 Thomas Koenig PR fortran/78221 * gfortran.dg/warn_conversion_9.f90: New test. From-SVN: r241884 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/arith.c | 8 ++++---- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/warn_conversion_9.f90 | 7 +++++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/warn_conversion_9.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 41225b55650..5c25988c026 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-11-06 Thomas Koenig + + PR fortran/78221 + * arith.c (gfc_complex2real): Change gfc_warning_now to + gfc_warning. + 2016-11-05 Paul Thomas * check.c (gfc_check_move_alloc): Introduce error to prevent diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c index d566faa29cd..2781f103841 100644 --- a/gcc/fortran/arith.c +++ b/gcc/fortran/arith.c @@ -2369,10 +2369,10 @@ gfc_complex2real (gfc_expr *src, int kind) /* See if we discarded an imaginary part. */ if (mpfr_cmp_si (mpc_imagref (src->value.complex), 0) != 0) { - gfc_warning_now (w, "Non-zero imaginary part discarded " - "in conversion from %qs to %qs at %L", - gfc_typename(&src->ts), gfc_typename (&result->ts), - &src->where); + gfc_warning (w, "Non-zero imaginary part discarded " + "in conversion from %qs to %qs at %L", + gfc_typename(&src->ts), gfc_typename (&result->ts), + &src->where); did_warn = true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 69af2ef7025..f6bdc414fed 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-11-06 Thomas Koenig + + PR fortran/78221 + * arith.c (gfc_complex2real): Change gfc_warning_now to + gfc_warning. + 2016-11-05 Paul Thomas * gfortran.dg/move_alloc_17.f03: New test. diff --git a/gcc/testsuite/gfortran.dg/warn_conversion_9.f90 b/gcc/testsuite/gfortran.dg/warn_conversion_9.f90 new file mode 100644 index 00000000000..794eeef99b6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/warn_conversion_9.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! { dg-options "-Wconversion" } +! PR 78221 - used to give a spurious warning +complex, parameter :: i = (0.,1.) +complex :: t +t = (i) +end -- 2.30.2