+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.
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;
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
Fortran Warning
Warn about unused dummy arguments.
+Wzerotrip
+Fortran Warning
+Warn about zero-trip DO loops
+
cpp
Fortran Negative(nocpp)
Enable preprocessing
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;
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;
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;
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);
}
+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
! 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)
! { 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'.
! { 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
! { dg-do run }
-! { dg-options "-fcoarray=single" }
+! { dg-options "-fcoarray=single -Wzerotrip" }
!
! PR fortran/18918
!
! { dg-do run }
+! { dg-options "-Wall" }
! Program to check corner cases for DO statements.
program do_1
implicit none
! { 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
--- /dev/null
+! { dg-do compile }
+! { dg-options "-Wall -Wno-zerotrip" }
+program main
+ do i=1,0
+ print *,i
+ end do
+end program main
! { dg-do compile }
-!
+! { dg-options "-Wall" }
! PR/fortran 38432
! DO-loop compile-time checks
!