Bug 56666 - Suppression flag for " DO loop at (1) will be executed zero times"
Summary: Suppression flag for " DO loop at (1) will be executed zero times"
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 enhancement
Target Milestone: ---
Assignee: Thomas Koenig
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-20 12:21 UTC by Troels Haugboelle
Modified: 2013-08-12 06:04 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-07-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Troels Haugboelle 2013-03-20 12:21:07 UTC
When running the gfortran compiler on source files with zero-trip do loops, such as

do i=1,0
  ...do..something...
enddo

the compiler will complain with the warning :

Warning: DO loop at (1) will be executed zero times
test.f90:10.12:

   do i=1,0
           1
Warning: DO loop at (1) will be executed zero times

We have a code, which makes use of preprocessing to select different configurations. In the default configuration there are hundreds of these kind of loops. The warning makes it harder to spot other warnings and errors.

It would be nice if it were possible to suppress/enable the warning with a flag like

-Wzerotrip
-Wno-zerotrip
Comment 1 Thomas Koenig 2013-07-21 21:50:28 UTC
Confirmed.
Comment 2 Thomas Koenig 2013-08-12 05:53:31 UTC
Author: tkoenig
Date: Mon Aug 12 05:50:03 2013
New Revision: 201658

URL: http://gcc.gnu.org/viewcvs?rev=201658&root=gcc&view=rev
Log:
2013-08-12  Thomas Koenig  <tkoenig@gcc.gnu.org>

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

	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.


Added:
    trunk/gcc/testsuite/gfortran.dg/do_check_10.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/invoke.texi
    trunk/gcc/fortran/lang.opt
    trunk/gcc/fortran/options.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/array_constructor_11.f90
    trunk/gcc/testsuite/gfortran.dg/array_constructor_18.f90
    trunk/gcc/testsuite/gfortran.dg/array_constructor_22.f90
    trunk/gcc/testsuite/gfortran.dg/coarray_15.f90
    trunk/gcc/testsuite/gfortran.dg/do_1.f90
    trunk/gcc/testsuite/gfortran.dg/do_3.F90
    trunk/gcc/testsuite/gfortran.dg/do_check_5.f90
Comment 3 Thomas Koenig 2013-08-12 06:04:06 UTC
Files modified in the GCC repository. Log entry:

2013-08-12  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* gcc-4.9/changes.html:  Document -Wzerotrip.