From 396e56d2da7935f96f4ca133c359668cc6c98eaf Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sun, 30 Oct 2016 17:48:27 +0000 Subject: [PATCH] re PR fortran/67219 (Incorrect conversion warning) 2016-10-30 Thomas Koenig PR fortran/67219 * arith.c (gfc_int2real): Change gfc_warning_now to gfc_warning. * primary.c (match_complex_constant): If there is no comma, throw away any warning which might have been issued by gfc_int2real. 2016-10-30 Thomas Koenig PR fortran/67219 * gfortran.dg/pr67219.f90: New test. From-SVN: r241689 --- gcc/fortran/ChangeLog | 9 +++++++++ gcc/fortran/arith.c | 10 +++++----- gcc/fortran/primary.c | 4 ++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr67219.f90 | 8 ++++++++ 5 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr67219.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 684af2f0d2e..be4f1b8f03f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2016-10-30 Thomas Koenig + + PR fortran/67219 + * arith.c (gfc_int2real): Change gfc_warning_now + to gfc_warning. + * primary.c (match_complex_constant): If there + is no comma, throw away any warning which might have + been issued by gfc_int2real. + 2016-10-28 Steven G. Kargl PR fortran/71891 diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c index 8af75400d80..d566faa29cd 100644 --- a/gcc/fortran/arith.c +++ b/gcc/fortran/arith.c @@ -2072,11 +2072,11 @@ gfc_int2real (gfc_expr *src, int kind) if (warn_conversion && wprecision_int_real (src->value.integer, result->value.real)) - gfc_warning_now (OPT_Wconversion, "Change of value in conversion " - "from %qs to %qs at %L", - gfc_typename (&src->ts), - gfc_typename (&result->ts), - &src->where); + gfc_warning (OPT_Wconversion, "Change of value in conversion " + "from %qs to %qs at %L", + gfc_typename (&src->ts), + gfc_typename (&result->ts), + &src->where); return result; } diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index bcbaeaa6369..2101644fcdc 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -1353,6 +1353,10 @@ match_complex_constant (gfc_expr **result) if (gfc_match_char (',') == MATCH_NO) { + /* It is possible that gfc_int2real issued a warning when + converting an integer to real. Throw this away here. */ + + gfc_clear_warning (); gfc_pop_error (&old_error); m = MATCH_NO; goto cleanup; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7ebc61642d2..d65ebb4a8ce 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-10-30 Thomas Koenig + + PR fortran/67219 + * gfortran.dg/pr67219.f90: New test. + 2016-10-29 Jakub Jelinek PR rtl-optimization/77919 diff --git a/gcc/testsuite/gfortran.dg/pr67219.f90 b/gcc/testsuite/gfortran.dg/pr67219.f90 new file mode 100644 index 00000000000..26d5f3f5cae --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr67219.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR 67149 - this used to throw a spurious error. +function foo(bar) + integer(8) :: foo + integer(4), intent(in) :: bar + integer(4), parameter :: huge_4 = huge(0_4) + foo = (huge_4 - int(bar,kind=8)) +end function -- 2.30.2