diff mbox

[fortran] Fix PR 67219, erroneous warning

Message ID 23b20f03-ca1f-defc-c5de-c3bd09524bf0@netcologne.de
State New
Headers show

Commit Message

Thomas Koenig Oct. 30, 2016, 4:32 p.m. UTC
Hello world,

the regression in question was caused by issuing a conversion
warning for a complex constant too early, when the statement would be
rejected later.

The solution is to throw away the warning if we do not find that
comma.

Regression-tested.  OK for trunk and 6-branch?

Regards

	Thomas

2016-10-30  Thomas Koenig  <tkoenig@gcc.gnu.org>

         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  <tkoenig@gcc.gnu.org>

         PR fortran/67219
         * gfortran.dg/pr67219.f90:  New test.

Comments

Steve Kargl Oct. 30, 2016, 5:34 p.m. UTC | #1
On Sun, Oct 30, 2016 at 05:32:52PM +0100, Thomas Koenig wrote:
> 

> the regression in question was caused by issuing a conversion

> warning for a complex constant too early, when the statement would be

> rejected later.

> 

> The solution is to throw away the warning if we do not find that

> comma.

> 

> Regression-tested.  OK for trunk and 6-branch?

> 


OK.

-- 
Steve
diff mbox

Patch

Index: arith.c
===================================================================
--- arith.c	(Revision 241590)
+++ arith.c	(Arbeitskopie)
@@ -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;
 }
Index: primary.c
===================================================================
--- primary.c	(Revision 241590)
+++ primary.c	(Arbeitskopie)
@@ -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;