From patchwork Sun Aug 11 21:51:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 266404 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 310672C009E for ; Mon, 12 Aug 2013 07:51:19 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=SbajpwyU1ZYD1a8up TtmdpcWiqyog5nvGT4vyGjgtdQvXunHzBaaGfNEarA6s8vWxqM7j/sWC6FLeFwOy x9TsCYbGTgYEegO8rOIz5zUC/WpeWHGpiD1ryUEkFF6jFiOQCKjbZrK8E+kYEM07 R6C6HgKNV/E2lwpmY1nzRRzCm8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=ICs9nQXI59WTOeMoT3l1SQ0 tfVc=; b=H2vGhhM5eg6X7s+E4ej7p22wAQvSOIsJypCr3shOkuUk7eeFhxld0Ji aFGkGQjS0Y5NjWZLZ6KLuhvdr0+59ChHv7Vw1YKu4/fFXXkKOzIxIArDAaHW6fFx 794heeqkf4000U+XhudmgzTmWFD8estwHZ9Z5OwD8FvVBNThrdr0= Received: (qmail 15591 invoked by alias); 11 Aug 2013 21:51:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 15568 invoked by uid 89); 11 Aug 2013 21:51:07 -0000 X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_NO, RP_MATCHES_RCVD, T_FRT_FREE autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 3 recipients Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 11 Aug 2013 21:51:06 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 9A16C12518; Sun, 11 Aug 2013 23:51:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 8B21D11DCB; Sun, 11 Aug 2013 23:51:03 +0200 (CEST) Received: from [84.44.177.89] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.0.0) (envelope-from ) id 52080747-05d7-7f0000012729-7f0000018f56-1 for ; Sun, 11 Aug 2013 23:51:03 +0200 Received: from [192.168.0.105] (xdsl-84-44-177-89.netcologne.de [84.44.177.89]) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Sun, 11 Aug 2013 23:51:01 +0200 (CEST) Message-ID: <52080744.2070609@netcologne.de> Date: Sun, 11 Aug 2013 23:51:00 +0200 From: Thomas Koenig User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: Janus Weil CC: "fortran@gcc.gnu.org" , gcc-patches Subject: Re: [patch, fortran] RFD: PR 56666 Allow suppression of zero-trip DO loop warning References: <51FD2FA9.508@netcologne.de> In-Reply-To: X-Virus-Found: No Hi Janus, > So: Ok for trunk from my side. > > However, I would prefer to disable the warning by default, but include > it in -Wall. Here's a patch to do just that. Regression-tested (hence the changes to the existing test cases :-) OK for trunk? Once it goes in, I will also update the WWW changes. Thomas 2013-08-03 Thomas Koenig PR fortran/56666 * gfortran.h (gfc_option_t): Add warn_zerotrip. * invoke.texi (-Wzerotrip): Document option. * lang.opt (Wzerotrip): Add. * options.c (gfc_init_options): Initialize warn_zerotrip. (set_Wall): Add handling of warn_zerotrip. (gfc_handle_option): Handle OPT_Wzerotrip. * resolve.c (gfc_resolve_iterator): Honor gfc_option.warn_zerotrip; update error message to show how to suppress the warning. 2013-08-03 Thomas Koenig PR fortran/56666 * gfortran.dg/do_check_10.f90: New test. * gfortran.dg/array_constructor_11.f90: Add -Wzerotrip to dg-options. * gfortran.dg/array_constructor_18.f90: Likewise. * gfortran.dg/array_constructor_22.f90: Likewise. * gfortran.dg/coarray_15.f90: Likewise. * gfortran.dg/do_1.f90: Add -Wall to dg-options. * gfortran.dg/do_3.F90: Add -Wzerotrip to dg-options. * gfortran.dg/do_check_5.f90: Add -Wall to gd-options. Index: fortran/gfortran.h =================================================================== --- fortran/gfortran.h (Revision 201448) +++ fortran/gfortran.h (Arbeitskopie) @@ -2252,6 +2252,7 @@ typedef struct int warn_align_commons; int warn_real_q_constant; int warn_unused_dummy_argument; + int warn_zerotrip; int warn_realloc_lhs; int warn_realloc_lhs_all; int warn_compare_reals; Index: fortran/invoke.texi =================================================================== --- fortran/invoke.texi (Revision 201448) +++ fortran/invoke.texi (Arbeitskopie) @@ -954,6 +954,11 @@ This option is implied by @option{-Wextra}. Warn if the pointer in a pointer assignment might be longer than the its target. This option is implied by @option{-Wall}. +@item -Wzerotrip +@opindex @code{Wzerotrip} +Warn if a @code{DO} loop is known to execute zero times at compile +time. This option is implied by @option{-Wall}. + @item -Werror @opindex @code{Werror} @cindex warnings, to errors Index: fortran/lang.opt =================================================================== --- fortran/lang.opt (Revision 201448) +++ fortran/lang.opt (Arbeitskopie) @@ -293,6 +293,10 @@ Wunused-dummy-argument Fortran Warning Warn about unused dummy arguments. +Wzerotrip +Fortran Warning +Warn about zero-trip DO loops + cpp Fortran Negative(nocpp) Enable preprocessing Index: fortran/options.c =================================================================== --- fortran/options.c (Revision 201448) +++ fortran/options.c (Arbeitskopie) @@ -109,6 +109,7 @@ gfc_init_options (unsigned int decoded_options_cou gfc_option.warn_align_commons = 1; gfc_option.warn_real_q_constant = 0; gfc_option.warn_unused_dummy_argument = 0; + gfc_option.warn_zerotrip = 0; gfc_option.warn_realloc_lhs = 0; gfc_option.warn_realloc_lhs_all = 0; gfc_option.warn_compare_reals = 0; @@ -466,6 +467,7 @@ set_Wall (int setting) gfc_option.warn_real_q_constant = setting; gfc_option.warn_unused_dummy_argument = setting; gfc_option.warn_target_lifetime = setting; + gfc_option.warn_zerotrip = setting; warn_return_type = setting; warn_uninitialized = setting; @@ -747,6 +749,10 @@ gfc_handle_option (size_t scode, const char *arg, gfc_option.warn_unused_dummy_argument = value; break; + case OPT_Wzerotrip: + gfc_option.warn_zerotrip = value; + break; + case OPT_fall_intrinsics: gfc_option.flag_all_intrinsics = 1; break; Index: fortran/resolve.c =================================================================== --- fortran/resolve.c (Revision 201448) +++ fortran/resolve.c (Arbeitskopie) @@ -6282,8 +6282,10 @@ gfc_resolve_iterator (gfc_iterator *iter, bool rea sgn = mpfr_sgn (iter->step->value.real); cmp = mpfr_cmp (iter->end->value.real, iter->start->value.real); } - if ((sgn > 0 && cmp < 0) || (sgn < 0 && cmp > 0)) - gfc_warning ("DO loop at %L will be executed zero times", + if (gfc_option.warn_zerotrip && + ((sgn > 0 && cmp < 0) || (sgn < 0 && cmp > 0))) + gfc_warning ("DO loop at %L will be executed zero times" + " (use -Wno-zerotrip to suppress)", &iter->step->where); } Index: testsuite/gfortran.dg/array_constructor_11.f90 =================================================================== --- testsuite/gfortran.dg/array_constructor_11.f90 (Revision 201448) +++ testsuite/gfortran.dg/array_constructor_11.f90 (Arbeitskopie) @@ -1,6 +1,7 @@ ! Like array_constructor_6.f90, but check iterators with non-default stride, ! including combinations which lead to zero-length vectors. ! { dg-do run } +! { dg-options "-Wzerotrip" } program main implicit none call build (77) Index: testsuite/gfortran.dg/array_constructor_18.f90 =================================================================== --- testsuite/gfortran.dg/array_constructor_18.f90 (Revision 201448) +++ testsuite/gfortran.dg/array_constructor_18.f90 (Arbeitskopie) @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-Wzerotrip" } ! Tests the fix for PR32875, in which the character length for the ! array constructor would get lost in simplification and would lead ! the error 'Not Implemented: complex character array constructor'. Index: testsuite/gfortran.dg/array_constructor_22.f90 =================================================================== --- testsuite/gfortran.dg/array_constructor_22.f90 (Revision 201448) +++ testsuite/gfortran.dg/array_constructor_22.f90 (Arbeitskopie) @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-Wzerotrip" } ! PR34990 ICE in gfc_typenode_for_spec, at fortran/trans-types.c:842 ! Test case that of the reporters. module test Index: testsuite/gfortran.dg/coarray_15.f90 =================================================================== --- testsuite/gfortran.dg/coarray_15.f90 (Revision 201448) +++ testsuite/gfortran.dg/coarray_15.f90 (Arbeitskopie) @@ -1,5 +1,5 @@ ! { dg-do run } -! { dg-options "-fcoarray=single" } +! { dg-options "-fcoarray=single -Wzerotrip" } ! ! PR fortran/18918 ! Index: testsuite/gfortran.dg/do_1.f90 =================================================================== --- testsuite/gfortran.dg/do_1.f90 (Revision 201448) +++ testsuite/gfortran.dg/do_1.f90 (Arbeitskopie) @@ -1,4 +1,5 @@ ! { dg-do run } +! { dg-options "-Wall" } ! Program to check corner cases for DO statements. program do_1 implicit none Index: testsuite/gfortran.dg/do_3.F90 =================================================================== --- testsuite/gfortran.dg/do_3.F90 (Revision 201448) +++ testsuite/gfortran.dg/do_3.F90 (Arbeitskopie) @@ -1,5 +1,5 @@ ! { dg-do run } -! { dg-options "-std=legacy -ffree-line-length-none -fno-range-check -fwrapv" } +! { dg-options "-std=legacy -ffree-line-length-none -fno-range-check -fwrapv -Wzerotrip" } program test integer :: count integer :: i Index: testsuite/gfortran.dg/do_check_5.f90 =================================================================== --- testsuite/gfortran.dg/do_check_5.f90 (Revision 201448) +++ testsuite/gfortran.dg/do_check_5.f90 (Arbeitskopie) @@ -1,5 +1,5 @@ ! { dg-do compile } -! +! { dg-options "-Wall" } ! PR/fortran 38432 ! DO-loop compile-time checks !