diff mbox series

[fortran] Fix PR 88298

Message ID 486124b7-1df0-c772-4145-f0402b355438@netcologne.de
State New
Headers show
Series [fortran] Fix PR 88298 | expand

Commit Message

Thomas Koenig Feb. 2, 2019, 2:41 p.m. UTC
Hi,

the attached patch fixes a 7/8/9 regression where a conversion warning
was emitted for DIM.  The problem was that the no-warn flag had not been
passed down to the arithmetic conversion routines, which is solved here
by adding and using a flag in gfc_expr.

Regression-tested.  OK for affected branches?

Regards

	Thomas

2019-02-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/88298
         * arith.c (gfc_int2int): Do not warn if src->do_not_warn is set.
         * gfortran.h (gfc_expr): Add flag do_not_warn.
         * intrinsic.c (gfc_convert_type_warn): Set expr->do_not_warn if
         no warning is desired.

2019-02-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/88298
         * gfortran.dg/warn_conversion_10.f90: New test.

Comments

Paul Richard Thomas Feb. 2, 2019, 4:13 p.m. UTC | #1
OK - thanks for the patch.

Paul

On Sat, 2 Feb 2019 at 14:41, Thomas Koenig <tkoenig@netcologne.de> wrote:
>
> Hi,
>
> the attached patch fixes a 7/8/9 regression where a conversion warning
> was emitted for DIM.  The problem was that the no-warn flag had not been
> passed down to the arithmetic conversion routines, which is solved here
> by adding and using a flag in gfc_expr.
>
> Regression-tested.  OK for affected branches?
>
> Regards
>
>         Thomas
>
> 2019-02-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
>
>          PR fortran/88298
>          * arith.c (gfc_int2int): Do not warn if src->do_not_warn is set.
>          * gfortran.h (gfc_expr): Add flag do_not_warn.
>          * intrinsic.c (gfc_convert_type_warn): Set expr->do_not_warn if
>          no warning is desired.
>
> 2019-02-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
>
>          PR fortran/88298
>          * gfortran.dg/warn_conversion_10.f90: New test.
diff mbox series

Patch

Index: arith.c
===================================================================
--- arith.c	(Revision 268432)
+++ arith.c	(Arbeitskopie)
@@ -2061,7 +2061,7 @@  gfc_int2int (gfc_expr *src, int kind)
       gfc_convert_mpz_to_signed (result->value.integer,
 				 gfc_integer_kinds[k].bit_size);
 
-      if (warn_conversion && kind < src->ts.kind)
+      if (warn_conversion && !src->do_not_warn && kind < src->ts.kind)
 	gfc_warning_now (OPT_Wconversion, "Conversion from %qs to %qs at %L",
 			 gfc_typename (&src->ts), gfc_typename (&result->ts),
 			 &src->where);
Index: gfortran.h
===================================================================
--- gfortran.h	(Revision 268432)
+++ gfortran.h	(Arbeitskopie)
@@ -2168,6 +2168,9 @@  typedef struct gfc_expr
 
   unsigned int do_not_resolve_again : 1;
 
+  /* Set this if no warning should be given somewhere in a lower level.  */
+
+  unsigned int do_not_warn : 1;
   /* If an expression comes from a Hollerith constant or compile-time
      evaluation of a transfer statement, it may have a prescribed target-
      memory representation, and these cannot always be backformed from
Index: intrinsic.c
===================================================================
--- intrinsic.c	(Revision 268432)
+++ intrinsic.c	(Arbeitskopie)
@@ -5028,6 +5028,8 @@  gfc_convert_type_warn (gfc_expr *expr, gfc_typespe
   if (ts->type == BT_UNKNOWN)
     goto bad;
 
+  expr->do_not_warn = ! wflag;
+
   /* NULL and zero size arrays get their type here, unless they already have a
      typespec.  */
   if ((expr->expr_type == EXPR_NULL