Silence additional warning in gfortran.dg/do_subscript_3.f90

Message ID 20211110145947.GH97553@kam.mff.cuni.cz
State New
Headers
Series Silence additional warning in gfortran.dg/do_subscript_3.f90 |

Commit Message

Jan Hubicka Nov. 10, 2021, 2:59 p.m. UTC
  Hi,
the testcase tests for out of bound accesses warnings and with ipa-modref improvements
it now triggers a new warning:

/aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:11:9: Warning: (1)
/aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:10:47: Warning: Array reference at (1) out of bounds (0 < 1) in loop beginning at (2)
/aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:19:9: Warning: (1)
/aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:18:45: Warning: Array reference at (1) out of bounds (6 > 5) in loop beginning at (2)
/aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:19:50: Warning: iteration 5 invokes undefined behavior [-Waggressive-loop-optimizations]
/aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:18:9: note: within this loop

I suppose we now are able to propagate array bounds better into the
nested function.

The last warning is new and correct even though little bit redundant.  I think
we may just silence it?  I wonder why we do not get same fact on the first loop
(which hits out of bound access already at iteration 0).

Looks OK?
Honza

gcc/testsuite/ChangeLog:

2021-11-10  Jan Hubicka  <hubicka@ucw.cz>

	* gfortran.dg/do_subscript_3.f90: Add -Wno-aggressive-loop-optimizations.
  

Comments

Richard Biener Nov. 11, 2021, 7:18 a.m. UTC | #1
On Wed, Nov 10, 2021 at 4:00 PM Jan Hubicka via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
> the testcase tests for out of bound accesses warnings and with ipa-modref improvements
> it now triggers a new warning:
>
> /aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:11:9: Warning: (1)
> /aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:10:47: Warning: Array reference at (1) out of bounds (0 < 1) in loop beginning at (2)
> /aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:19:9: Warning: (1)
> /aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:18:45: Warning: Array reference at (1) out of bounds (6 > 5) in loop beginning at (2)
> /aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:19:50: Warning: iteration 5 invokes undefined behavior [-Waggressive-loop-optimizations]
> /aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:18:9: note: within this loop
>
> I suppose we now are able to propagate array bounds better into the
> nested function.
>
> The last warning is new and correct even though little bit redundant.  I think
> we may just silence it?  I wonder why we do not get same fact on the first loop
> (which hits out of bound access already at iteration 0).
>
> Looks OK?

I guess so - but it looks like the testcase exercises diagnostics in
the frontend so I wonder
whether simply using { dg-options "-O0" } might be more appropriate?

> Honza
>
> gcc/testsuite/ChangeLog:
>
> 2021-11-10  Jan Hubicka  <hubicka@ucw.cz>
>
>         * gfortran.dg/do_subscript_3.f90: Add -Wno-aggressive-loop-optimizations.
>
> diff --git a/gcc/testsuite/gfortran.dg/do_subscript_3.f90 b/gcc/testsuite/gfortran.dg/do_subscript_3.f90
> index 2f62f58142b..18ed9a2f0c9 100644
> --- a/gcc/testsuite/gfortran.dg/do_subscript_3.f90
> +++ b/gcc/testsuite/gfortran.dg/do_subscript_3.f90
> @@ -1,4 +1,5 @@
>  ! { dg-do compile }
> +! { dg-additional-options "-Wno-aggressive-loop-optimizations" }
>  ! PR fortran/91424
>  ! Check that only one warning is issued inside blocks, and that
>  ! warnings are also issued for contained subroutines.
  

Patch

diff --git a/gcc/testsuite/gfortran.dg/do_subscript_3.f90 b/gcc/testsuite/gfortran.dg/do_subscript_3.f90
index 2f62f58142b..18ed9a2f0c9 100644
--- a/gcc/testsuite/gfortran.dg/do_subscript_3.f90
+++ b/gcc/testsuite/gfortran.dg/do_subscript_3.f90
@@ -1,4 +1,5 @@ 
 ! { dg-do compile }
+! { dg-additional-options "-Wno-aggressive-loop-optimizations" }
 ! PR fortran/91424
 ! Check that only one warning is issued inside blocks, and that
 ! warnings are also issued for contained subroutines.