Commit ad7082e3 by Tobias Schlüter

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
parent 0cf9e3a4
2006-12-12 Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
* trans-expr.c (gfc_conv_substring): Check for empty substring.
2006-12-11 Jan Hubicka <jh@suse.cz> 2006-12-11 Jan Hubicka <jh@suse.cz>
* 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 <burnus@net-b.de> 2006-12-10 Tobias Burnus <burnus@net-b.de>
......
...@@ -278,9 +278,14 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind, ...@@ -278,9 +278,14 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind,
} }
if (flag_bounds_check) if (flag_bounds_check)
{ {
tree nonempty = fold_build2 (LE_EXPR, boolean_type_node,
start.expr, end.expr);
/* Check lower bound. */ /* Check lower bound. */
fault = fold_build2 (LT_EXPR, boolean_type_node, start.expr, fault = fold_build2 (LT_EXPR, boolean_type_node, start.expr,
build_int_cst (gfc_charlen_type_node, 1)); build_int_cst (gfc_charlen_type_node, 1));
fault = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node,
nonempty, fault);
if (name) if (name)
asprintf (&msg, "Substring out of bounds: lower bound of '%s' " asprintf (&msg, "Substring out of bounds: lower bound of '%s' "
"is less than one", name); "is less than one", name);
...@@ -293,6 +298,8 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind, ...@@ -293,6 +298,8 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind,
/* Check upper bound. */ /* Check upper bound. */
fault = fold_build2 (GT_EXPR, boolean_type_node, end.expr, fault = fold_build2 (GT_EXPR, boolean_type_node, end.expr,
se->string_length); se->string_length);
fault = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node,
nonempty, fault);
if (name) if (name)
asprintf (&msg, "Substring out of bounds: upper bound of '%s' " asprintf (&msg, "Substring out of bounds: upper bound of '%s' "
"exceeds string length", name); "exceeds string length", name);
......
2006-12-12 Tobias Schlter <tobias.schlueter@physik.uni-muenchen.de>
* 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 <richard@codesourcery.com> 2006-12-12 Richard Sandiford <richard@codesourcery.com>
* lib/gcc-dg.exp (${tool}_load): Fix invocation of * lib/gcc-dg.exp (${tool}_load): Fix invocation of
...@@ -8,7 +8,7 @@ program main ...@@ -8,7 +8,7 @@ program main
do i3 = 1, n3 do i3 = 1, n3
do i1 = 1, n1 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
end do end do
......
...@@ -8,7 +8,7 @@ program main ...@@ -8,7 +8,7 @@ program main
do i2 = 1, n2 do i2 = 1, n2
do i1 = 1, n1 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
end do end do
......
...@@ -14,26 +14,26 @@ contains ...@@ -14,26 +14,26 @@ contains
subroutine foo1 (xmin) subroutine foo1 (xmin)
real, intent(inout) :: xmin(:) real, intent(inout) :: xmin(:)
real :: x(size(xmin)+1) ! The declaration for r would be added 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 xmin = r
if (size(r) .ne. 9) call abort () if (size(r) .ne. 10) call abort ()
if (size(x) .ne. 11) call abort () if (size(x) .ne. 11) call abort ()
end subroutine foo1 end subroutine foo1
subroutine foo2 (xmin) ! This version was OK because of the subroutine foo2 (xmin) ! This version was OK because of the
real, intent(inout) :: xmin(:) ! renaming of r which pushed it up real, intent(inout) :: xmin(:) ! renaming of r which pushed it up
real :: x(size(xmin)+3) ! the symtree. real :: x(size(xmin)+3) ! the symtree.
real :: zr(size(x)-6) real :: zr(size(x)-3)
xmin = zr xmin = zr
if (size(zr) .ne. 7) call abort () if (size(zr) .ne. 10) call abort ()
if (size(x) .ne. 13) call abort () if (size(x) .ne. 13) call abort ()
end subroutine foo2 end subroutine foo2
subroutine foo3 (xmin) subroutine foo3 (xmin)
real, intent(inout) :: xmin(:) real, intent(inout) :: xmin(:)
character(size(x)+2) :: y ! host associated x character(size(x)+2) :: y ! host associated x
character(len(y)+3) :: z ! This did not work for any combination 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 xmin = r
if (size(r) .ne. 5) call abort () if (size(r) .ne. 10) call abort ()
if (len(z) .ne. 15) call abort () if (len(z) .ne. 15) call abort ()
end subroutine foo3 end subroutine foo3
end program bar end program bar
! { dg-do run } ! { dg-do run }
! { dg-additional-sources enum_10.c } ! { dg-additional-sources enum_10.c }
! { dg-options "-fshort-enums" } ! { dg-options "-fshort-enums -w" }
! Make sure short enums are indeed interoperable with the ! Make sure short enums are indeed interoperable with the
! corresponding C type. ! corresponding C type.
......
c { dg-do run } c { dg-do run }
c { dg-options "-fno-bounds-check" }
CCC g77 0.5.21 `Actual Bugs': CCC g77 0.5.21 `Actual Bugs':
CCC * A code-generation bug afflicts Intel x86 targets when `-O2' is CCC * A code-generation bug afflicts Intel x86 targets when `-O2' is
CCC specified compiling, for example, an old version of the `DNRM2' CCC specified compiling, for example, an old version of the `DNRM2'
......
! { dg-do run } ! { dg-do run }
! { dg-additional-sources mixed_io_1.c } ! { dg-additional-sources mixed_io_1.c }
! { dg-options "-w" }
call cio call cio
write(*,"(A)") '6789' ! { dg-output "123456789" } write(*,"(A)") '6789' ! { dg-output "123456789" }
end end
# 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -20,24 +20,54 @@ ...@@ -20,24 +20,54 @@
# This file was written by Steven Bosscher (s.bosscher@student.tudelft.nl) # This file was written by Steven Bosscher (s.bosscher@student.tudelft.nl)
# based on f-torture.exp, which was written by Rob Savoye. # 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 # The default option list can be overridden by
# TORTURE_OPTIONS="{ { list1 } ... { listN } }" # TORTURE_OPTIONS="{ { list1 } ... { listN } }"
if ![info exists TORTURE_OPTIONS] { 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 \ set TORTURE_OPTIONS [list \
{ -O0 } { -O1 } { -O2 } \ { -O0 } { -O1 } { -O2 } \
{ -O2 -fomit-frame-pointer -finline-functions } \ { -O2 -fomit-frame-pointer -finline-functions } \
{ -O2 -fomit-frame-pointer -finline-functions -funroll-loops } \ { -O2 -fomit-frame-pointer -finline-functions -funroll-loops } \
{ -O2 -fbounds-check } \ { -O2 -fbounds-check } \
{ -O2 -fno-repack-arrays } \
{ -O3 -g } \ { -O3 -g } \
{ -Os }] { -Os }]
if { $test_tree_vectorize } {
lappend TORTURE_OPTIONS $vectorizer_options
}
} }
......
# 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
load_lib fortran-torture.exp
load_lib gcc-dg.exp load_lib gcc-dg.exp
# Define gfortran callbacks for dg.exp. # Define gfortran callbacks for dg.exp.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment