From: Thomas Koenig Date: Sat, 2 Feb 2019 16:21:43 +0000 (+0000) Subject: re PR fortran/88298 (Bogus conversion warning for CSHIFT with -fno-range-check -m64) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5197d79937c3dcf57e1a3be4e624947220d4c8f8;p=gcc.git re PR fortran/88298 (Bogus conversion warning for CSHIFT with -fno-range-check -m64) 2019-02-02 Thomas Koenig 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 PR fortran/88298 * gfortran.dg/warn_conversion_10.f90: New test. From-SVN: r268475 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ce6df90aa77..622af1e3902 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2019-02-02 Thomas Koenig + + 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 Paul Thomas PR fortran/88393 diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c index 99fb61c15b9..425345c99a3 100644 --- a/gcc/fortran/arith.c +++ b/gcc/fortran/arith.c @@ -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); diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index e7a9b6f5674..9643deba129 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -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 diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index 8d80869b9bc..f8d3a69d46d 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -5028,6 +5028,8 @@ gfc_convert_type_warn (gfc_expr *expr, gfc_typespec *ts, int eflag, int wflag) 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 727dc4bf43b..904a5911d77 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-02 Thomas Koenig + + PR fortran/88298 + * gfortran.dg/warn_conversion_10.f90: New test. + 2019-02-02 Paul Thomas PR fortran/88393 diff --git a/gcc/testsuite/gfortran.dg/warn_conversion_10.f90 b/gcc/testsuite/gfortran.dg/warn_conversion_10.f90 new file mode 100644 index 00000000000..e7d0a3ce104 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/warn_conversion_10.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! { dg-options "-fno-range-check -Wconversion" } +! PR 88298 - this used to warn unnecessarily. Original test case by +! Harald Anlauf. +subroutine bug (j, js) + integer :: j, js(3,2) + js(:,:) = cshift (js(:,:), shift=j, dim=1) +end subroutine bug