From ad7082e3d95afb5f313a8663050876ef5fd35534 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Schl=C3=BCter?= Date: Tue, 12 Dec 2006 21:59:21 +0100 Subject: [PATCH] trans-expr.c (gfc_conv_substring): Check for empty substring. fortran/ * trans-expr.c (gfc_conv_substring): Check for empty substring. testsuite/ * lib/fortran-torture.exp: Update copyright years. Remove obsolete comment. Test -ftree-vectorize where it makes sense. * lib/gfortran-dg.exp: Update copyright years. Use settings from fortran-torture.exp. * gfortran.dg/char_transpose_1.f90, gfortran.dg/char_spread_1.f90, gfortran.dg/g77/dnrm2.f, gfortran.dg/dependent_decls_1.f90: Fixout-of-bound errors. * gfortran.dg/enum_10.f90, gfortran.dg/mixed_io_1.f90: Add '-w' to dg-options. From-SVN: r119797 --- gcc/fortran/ChangeLog | 7 ++- gcc/fortran/trans-expr.c | 7 +++ gcc/testsuite/ChangeLog | 12 +++++ gcc/testsuite/gfortran.dg/char_spread_1.f90 | 2 +- .../gfortran.dg/char_transpose_1.f90 | 2 +- .../gfortran.dg/dependent_decls_1.f90 | 12 ++--- gcc/testsuite/gfortran.dg/enum_10.f90 | 2 +- gcc/testsuite/gfortran.dg/g77/dnrm2.f | 1 + gcc/testsuite/gfortran.dg/mixed_io_1.f90 | 1 + gcc/testsuite/lib/fortran-torture.exp | 44 ++++++++++++++++--- gcc/testsuite/lib/gfortran-dg.exp | 3 +- 11 files changed, 75 insertions(+), 18 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e3b685206ebe..eb9efa1b9cdd 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,6 +1,11 @@ +2006-12-12 Tobias Schlüter + + * trans-expr.c (gfc_conv_substring): Check for empty substring. + 2006-12-11 Jan Hubicka - * f59-lang.c (gfc_expand_function): Update for renamed varpool functions. + * f95-lang.c (gfc_expand_function): Update for renamed varpool + functions. 2006-12-10 Tobias Burnus diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 7c064ffd827f..04736d5a1da8 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -278,9 +278,14 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind, } if (flag_bounds_check) { + tree nonempty = fold_build2 (LE_EXPR, boolean_type_node, + start.expr, end.expr); + /* Check lower bound. */ fault = fold_build2 (LT_EXPR, boolean_type_node, start.expr, build_int_cst (gfc_charlen_type_node, 1)); + fault = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node, + nonempty, fault); if (name) asprintf (&msg, "Substring out of bounds: lower bound of '%s' " "is less than one", name); @@ -293,6 +298,8 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind, /* Check upper bound. */ fault = fold_build2 (GT_EXPR, boolean_type_node, end.expr, se->string_length); + fault = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node, + nonempty, fault); if (name) asprintf (&msg, "Substring out of bounds: upper bound of '%s' " "exceeds string length", name); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6f84fa551881..16e08e0590eb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2006-12-12 Tobias Schlüter + + * lib/fortran-torture.exp: Update copyright years. Remove + obsolete comment. Test -ftree-vectorize where it makes sense. + * lib/gfortran-dg.exp: Update copyright years. Use settings + from fortran-torture.exp. + * gfortran.dg/char_transpose_1.f90, + gfortran.dg/char_spread_1.f90, gfortran.dg/g77/dnrm2.f, + gfortran.dg/dependent_decls_1.f90: Fixout-of-bound errors. + * gfortran.dg/enum_10.f90, gfortran.dg/mixed_io_1.f90: Add + '-w' to dg-options. + 2006-12-12 Richard Sandiford * lib/gcc-dg.exp (${tool}_load): Fix invocation of diff --git a/gcc/testsuite/gfortran.dg/char_spread_1.f90 b/gcc/testsuite/gfortran.dg/char_spread_1.f90 index 0d51f6046d55..bb152ee394d6 100644 --- a/gcc/testsuite/gfortran.dg/char_spread_1.f90 +++ b/gcc/testsuite/gfortran.dg/char_spread_1.f90 @@ -8,7 +8,7 @@ program main do i3 = 1, n3 do i1 = 1, n1 - a (i1, i3) = 'ab'(i1:i1) // 'cde'(i3:i3) // 'cantrip' + a (i1, i3) = 'abc'(i1:i1) // 'defg'(i3:i3) // 'cantrip' end do end do diff --git a/gcc/testsuite/gfortran.dg/char_transpose_1.f90 b/gcc/testsuite/gfortran.dg/char_transpose_1.f90 index 90605d6458de..4b9c21a2ff4a 100644 --- a/gcc/testsuite/gfortran.dg/char_transpose_1.f90 +++ b/gcc/testsuite/gfortran.dg/char_transpose_1.f90 @@ -8,7 +8,7 @@ program main do i2 = 1, n2 do i1 = 1, n1 - a (i1, i2) = 'ab'(i1:i1) // 'cde'(i2:i2) // 'cantrip' + a (i1, i2) = 'abc'(i1:i1) // 'defg'(i2:i2) // 'cantrip' end do end do diff --git a/gcc/testsuite/gfortran.dg/dependent_decls_1.f90 b/gcc/testsuite/gfortran.dg/dependent_decls_1.f90 index 675c4a0d00d6..cca0eae5178a 100644 --- a/gcc/testsuite/gfortran.dg/dependent_decls_1.f90 +++ b/gcc/testsuite/gfortran.dg/dependent_decls_1.f90 @@ -14,26 +14,26 @@ contains subroutine foo1 (xmin) real, intent(inout) :: xmin(:) real :: x(size(xmin)+1) ! The declaration for r would be added - real :: r(size(x)-2) ! to the function before that of x + real :: r(size(x)-1) ! to the function before that of x xmin = r - if (size(r) .ne. 9) call abort () + if (size(r) .ne. 10) call abort () if (size(x) .ne. 11) call abort () end subroutine foo1 subroutine foo2 (xmin) ! This version was OK because of the real, intent(inout) :: xmin(:) ! renaming of r which pushed it up real :: x(size(xmin)+3) ! the symtree. - real :: zr(size(x)-6) + real :: zr(size(x)-3) xmin = zr - if (size(zr) .ne. 7) call abort () + if (size(zr) .ne. 10) call abort () if (size(x) .ne. 13) call abort () end subroutine foo2 subroutine foo3 (xmin) real, intent(inout) :: xmin(:) character(size(x)+2) :: y ! host associated x character(len(y)+3) :: z ! This did not work for any combination - real :: r(len(z)-10) ! of names. + real :: r(len(z)-5) ! of names. xmin = r - if (size(r) .ne. 5) call abort () + if (size(r) .ne. 10) call abort () if (len(z) .ne. 15) call abort () end subroutine foo3 end program bar diff --git a/gcc/testsuite/gfortran.dg/enum_10.f90 b/gcc/testsuite/gfortran.dg/enum_10.f90 index f1582191792a..6bfd819097ec 100644 --- a/gcc/testsuite/gfortran.dg/enum_10.f90 +++ b/gcc/testsuite/gfortran.dg/enum_10.f90 @@ -1,6 +1,6 @@ ! { dg-do run } ! { dg-additional-sources enum_10.c } -! { dg-options "-fshort-enums" } +! { dg-options "-fshort-enums -w" } ! Make sure short enums are indeed interoperable with the ! corresponding C type. diff --git a/gcc/testsuite/gfortran.dg/g77/dnrm2.f b/gcc/testsuite/gfortran.dg/g77/dnrm2.f index 7d9402765a7f..dbf9f0d058df 100644 --- a/gcc/testsuite/gfortran.dg/g77/dnrm2.f +++ b/gcc/testsuite/gfortran.dg/g77/dnrm2.f @@ -1,4 +1,5 @@ c { dg-do run } +c { dg-options "-fno-bounds-check" } CCC g77 0.5.21 `Actual Bugs': CCC * A code-generation bug afflicts Intel x86 targets when `-O2' is CCC specified compiling, for example, an old version of the `DNRM2' diff --git a/gcc/testsuite/gfortran.dg/mixed_io_1.f90 b/gcc/testsuite/gfortran.dg/mixed_io_1.f90 index 0dc985cbbf6d..4ea719fb43d8 100644 --- a/gcc/testsuite/gfortran.dg/mixed_io_1.f90 +++ b/gcc/testsuite/gfortran.dg/mixed_io_1.f90 @@ -1,5 +1,6 @@ ! { dg-do run } ! { dg-additional-sources mixed_io_1.c } +! { dg-options "-w" } call cio write(*,"(A)") '6789' ! { dg-output "123456789" } end diff --git a/gcc/testsuite/lib/fortran-torture.exp b/gcc/testsuite/lib/fortran-torture.exp index 801fb43eb17d..b68a05ddad60 100644 --- a/gcc/testsuite/lib/fortran-torture.exp +++ b/gcc/testsuite/lib/fortran-torture.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,24 +20,54 @@ # This file was written by Steven Bosscher (s.bosscher@student.tudelft.nl) # based on f-torture.exp, which was written by Rob Savoye. -# The biggest change from g77 is that we always test all testcases with -# loop options, because it is much harder to figure out whether a testcase -# has loops if you have array syntax, like Fortran 95. In fact, the whole -# point of F95 is arrays, so loops show up in most testcases anyway. - # The default option list can be overridden by # TORTURE_OPTIONS="{ { list1 } ... { listN } }" if ![info exists TORTURE_OPTIONS] { + # determine if host supports vectorization, and the necessary set + # of options, based on code from testsuite/vect/vect.exp + + set vectorizer_options [list "-O2" "-ftree-vectorize"] + + if { [istarget "powerpc*-*-*"] + && [is-effective-target powerpc_altivec_ok] + && [check_vmx_hw_available] } { + lappend vectorizer_options "-maltivec" + set test_tree_vectorize 1 + } elseif { [istarget "spu-*-*"] } { + set test_tree_vectorize 1 + } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } { + lappend vectorizer_options "-msse2" + set test_tree_vectorize 1 + } elseif { [istarget "mipsisa64*-*-*"] + && [check_effective_target_mpaired_single] } { + lappend vectorizer_options "-mpaired-single" + set test_tree_vectorize 1 + } elseif [istarget "sparc*-*-*"] { + lappend vectorizer_options "-mcpu=ultrasparc" "-mvis" + set test_tree_vectorize 1 + } elseif { [istarget "alpha*-*-*"] + && [check_alpha_max_hw_available] } { + lappend vectorizer_options "-mmax" + set test_tree_vectorize 1 + } elseif [istarget "ia64-*-*"] { + set test_tree_vectorize 1 + } else { + set test_tree_vectorize 0 + } + set TORTURE_OPTIONS [list \ { -O0 } { -O1 } { -O2 } \ { -O2 -fomit-frame-pointer -finline-functions } \ { -O2 -fomit-frame-pointer -finline-functions -funroll-loops } \ { -O2 -fbounds-check } \ - { -O2 -fno-repack-arrays } \ { -O3 -g } \ { -Os }] + + if { $test_tree_vectorize } { + lappend TORTURE_OPTIONS $vectorizer_options + } } diff --git a/gcc/testsuite/lib/gfortran-dg.exp b/gcc/testsuite/lib/gfortran-dg.exp index 5a16a39a4cd4..4a4788508945 100644 --- a/gcc/testsuite/lib/gfortran-dg.exp +++ b/gcc/testsuite/lib/gfortran-dg.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,6 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +load_lib fortran-torture.exp load_lib gcc-dg.exp # Define gfortran callbacks for dg.exp. -- 2.47.3