]> gcc.gnu.org Git - gcc.git/commitdiff
re PR fortran/56666 (Suppression flag for " DO loop at (1) will be executed zero...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 12 Aug 2013 05:50:03 +0000 (05:50 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 12 Aug 2013 05:50:03 +0000 (05:50 +0000)
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.

From-SVN: r201658

15 files changed:
gcc/fortran/ChangeLog
gcc/fortran/gfortran.h
gcc/fortran/invoke.texi
gcc/fortran/lang.opt
gcc/fortran/options.c
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/array_constructor_11.f90
gcc/testsuite/gfortran.dg/array_constructor_18.f90
gcc/testsuite/gfortran.dg/array_constructor_22.f90
gcc/testsuite/gfortran.dg/coarray_15.f90
gcc/testsuite/gfortran.dg/do_1.f90
gcc/testsuite/gfortran.dg/do_3.F90
gcc/testsuite/gfortran.dg/do_check_10.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/do_check_5.f90

index c1adb88d1bc02c171201f26b96cd3af04fc47fe7..ba34ac1c5ab6d964c5337e0f8e654b4782e862fc 100644 (file)
@@ -1,3 +1,16 @@
+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-09  Janus Weil  <janus@gcc.gnu.org>
 
        * gfortran.h (gfc_get_code): Modified prototype.
index 5c617cad4f29cd28075af2f237cd9e3f1d073209..691aa8ca74c73d03cc8c8863c9cc9a16720d4672 100644 (file)
@@ -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 3af57a300f87d02fe7cd589e07f9ea15d3c48828..69bec275de97b0d30bdfd4c224960b099cb00d31 100644 (file)
@@ -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 61f77b4fc5f586084c4d02b1c97c797ef5bd9d7e..4f7993433d49e5b712b4f168bab288def97389b3 100644 (file)
@@ -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 908b47e68bb6bc2d90afa659df444d8c450dd8c2..3a9c508dc27e2c9be5b01c99662a65bea4a46792 100644 (file)
@@ -109,6 +109,7 @@ gfc_init_options (unsigned int decoded_options_count,
   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, int value,
       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 837bf1512bfd167b53d0955e6f17929f118efd5a..067288dd6dbbf00e8cd376e5d752be5d2d6edbb7 100644 (file)
@@ -6281,8 +6281,10 @@ gfc_resolve_iterator (gfc_iterator *iter, bool real_ok, bool own_scope)
          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 786070c546dac77422e83cc38d3cd98e96d4aa34..3ff0e588d6f8a00fb4bc95db2483acfd97c3ca8f 100644 (file)
@@ -1,3 +1,15 @@
+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.
+
 2013-08-11  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/53349
index bb9f0dddb1107363792a9ef331f714f24f79a3a7..410fbcb7ddf28e068c98750e68a79a7da16595ff 100644 (file)
@@ -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 c78976839d0dc69d2c2f3e44de05fac1177c5a94..6853c069633b0e2da59f4d5f9ba48d919c36b2ae 100644 (file)
@@ -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 0dcdaea68c1a1aed01432ee6a27badf73ade8e1c..f7cdb27423ce0996bbaff75c39266fff5233c8e1 100644 (file)
@@ -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 0aecb2f4e1181c3cbdf749749848f5d968c3ce50..ee01e61ccc1ebddc10ea4b36869e6e27d8d23737 100644 (file)
@@ -1,5 +1,5 @@
 ! { dg-do run }
-! { dg-options "-fcoarray=single" }
+! { dg-options "-fcoarray=single -Wzerotrip" }
 !
 ! PR fortran/18918
 !
index 171275af3f2d6d836070e7d1d759ab2c9baa580c..b041279f6d942374bbf90ad7b21138ecab86b710 100644 (file)
@@ -1,4 +1,5 @@
 ! { dg-do run }
+! { dg-options "-Wall" }
 ! Program to check corner cases for DO statements.
 program do_1
   implicit none
index 67723a508f43d8e621157aab9f46594c26d638d8..eb4751d6b060dc369431f9ebd8e6a7721ffc2ea9 100644 (file)
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/do_check_10.f90 b/gcc/testsuite/gfortran.dg/do_check_10.f90
new file mode 100644 (file)
index 0000000..016dab7
--- /dev/null
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! { dg-options "-Wall -Wno-zerotrip" }
+program main
+  do i=1,0
+    print *,i
+  end do
+end program main
index 3df7b14f0ebfd604411a5e8c02960acb3fd678ae..57930fd61ad7200d86eeb1b43dd2f176d0020eb1 100644 (file)
@@ -1,5 +1,5 @@
 ! { dg-do compile }
-! 
+! { dg-options "-Wall" }
 ! PR/fortran 38432
 ! DO-loop compile-time checks
 !
This page took 0.09239 seconds and 5 git commands to generate.