aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2012-05-14 22:39:23 +0300
committerJanne Blomqvist <jb@gcc.gnu.org>2012-05-14 22:39:23 +0300
commit80b91c0b39e7d65e3d89e49b5bf2ec40927f5a33 (patch)
tree1b4a3a8d4b65ec8d0a88de4f00b90d28ce493090 /gcc
parentf62866740b93747b2d3f1dd4d4637e6890e0fa22 (diff)
downloadgcc-80b91c0b39e7d65e3d89e49b5bf2ec40927f5a33.zip
gcc-80b91c0b39e7d65e3d89e49b5bf2ec40927f5a33.tar.gz
gcc-80b91c0b39e7d65e3d89e49b5bf2ec40927f5a33.tar.bz2
PR 52428 Range checking when reading integer values.
gcc/fortran ChangeLog: 2012-05-14 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/52428 * gfortran.texi: Update _gfortran_set_options documentation. * invoke.texi: Remove runtime behavior description of -fno-range-check. * trans-decl.c (create_main_function): Don't pass the range-check setting to the library. libgfortran ChangeLog: 2012-05-14 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/52428 * io/io.h (max_value): Rename to si_max, remove second argument. * io/list_read.c (convert_integer): Use unsigned types when parsing the digits, set max value depending on the sign. * io/read.c (max_value): Rename to si_max, remove second argument, simplify. (read_decimal): Set max value depending on sign, always check overflow. (read_radix): Calculate max unsigned value directly. * libgfortran.h (struct compile_options_t): Remove range_check field. * runtime/compile_options.c (set_options): Skip handling options[7]. (init_compile_options): Don't set removed field. gcc/testsuite ChangeLog: 2012-05-14 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/52428 * gfortran.dg/int_range_io_1.f90: New test. From-SVN: r187478
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog9
-rw-r--r--gcc/fortran/gfortran.texi8
-rw-r--r--gcc/fortran/invoke.texi13
-rw-r--r--gcc/fortran/trans-decl.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/int_range_io_1.f9034
6 files changed, 59 insertions, 19 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 5e1dba9..59cfa32 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2012-05-14 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR fortran/52428
+ * gfortran.texi: Update _gfortran_set_options documentation.
+ * invoke.texi: Remove runtime behavior description of
+ -fno-range-check.
+ * trans-decl.c (create_main_function): Don't pass the range-check
+ setting to the library.
+
2012-05-14 Tobias Burnus <burnus@net-b.de>
PR fortran/49110
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 96662c4..ffcd3ec 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -2740,15 +2740,13 @@ Default: enabled.
are (bitwise or-ed): GFC_RTCHECK_BOUNDS (1), GFC_RTCHECK_ARRAY_TEMPS (2),
GFC_RTCHECK_RECURSION (4), GFC_RTCHECK_DO (16), GFC_RTCHECK_POINTER (32).
Default: disabled.
-@item @var{option}[7] @tab If non zero, range checking is enabled.
-Default: enabled. See -frange-check (@pxref{Code Gen Options}).
@end multitable
@item @emph{Example}:
@smallexample
- /* Use gfortran 4.7 default options. */
- static int options[] = @{68, 511, 0, 0, 1, 1, 0, 1@};
- _gfortran_set_options (8, &options);
+ /* Use gfortran 4.8 default options. */
+ static int options[] = @{68, 511, 0, 0, 1, 1, 0@};
+ _gfortran_set_options (7, &options);
@end smallexample
@end table
diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index 8db869b..658ed23 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -166,8 +166,7 @@ and warnings}.
@item Runtime Options
@xref{Runtime Options,,Options for influencing runtime behavior}.
-@gccoptlist{-fconvert=@var{conversion} -fmax-subrecord-length=@var{length}
--fno-range-check @gol
+@gccoptlist{-fconvert=@var{conversion} -fmax-subrecord-length=@var{length} @gol
-frecord-marker=@var{length} -fsign-zero
}
@@ -1116,16 +1115,6 @@ representation for unformatted files.
The @code{CONVERT} specifier and the GFORTRAN_CONVERT_UNIT environment
variable override the default specified by @option{-fconvert}.}
-
-@item -fno-range-check
-@opindex @code{fno-range-check}
-Disable range checking of input values during integer @code{READ} operations.
-For example, GNU Fortran will give an error if an input value is
-outside of the relevant range of [@code{-HUGE()}:@code{HUGE()}]. In other words,
-with @code{INTEGER (kind=4) :: i} , attempting to read @math{-2147483648} will
-give an error unless @option{-fno-range-check} is given.
-
-
@item -frecord-marker=@var{length}
@opindex @code{frecord-marker=}@var{length}
Specify the length of record markers for unformatted files.
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 1354ad0..0480f95 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -5039,12 +5039,17 @@ create_main_function (tree fndecl)
build_int_cst (integer_type_node,
(gfc_option.rtcheck
& GFC_RTCHECK_BOUNDS)));
+ /* TODO: This is the -frange-check option, which no longer affects
+ library behavior; when bumping the library ABI this slot can be
+ reused for something else. As it is the last element in the
+ array, we can instead leave it out altogether.
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
build_int_cst (integer_type_node,
gfc_option.flag_range_check));
+ */
array_type = build_array_type (integer_type_node,
- build_index_type (size_int (7)));
+ build_index_type (size_int (6)));
array = build_constructor (array_type, v);
TREE_CONSTANT (array) = 1;
TREE_STATIC (array) = 1;
@@ -5059,7 +5064,7 @@ create_main_function (tree fndecl)
tmp = build_call_expr_loc (input_location,
gfor_fndecl_set_options, 2,
- build_int_cst (integer_type_node, 8), var);
+ build_int_cst (integer_type_node, 7), var);
gfc_add_expr_to_block (&body, tmp);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c160fae..d6a2adf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-14 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR fortran/52428
+ * gfortran.dg/int_range_io_1.f90: New test.
+
2012-05-14 Andi Kleen <ak@linux.intel.com>
Jakub Jelinek <jakub@redhat.com>
diff --git a/gcc/testsuite/gfortran.dg/int_range_io_1.f90 b/gcc/testsuite/gfortran.dg/int_range_io_1.f90
new file mode 100644
index 0000000..de1fdb8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/int_range_io_1.f90
@@ -0,0 +1,34 @@
+! { dg-do run }
+! { dg-options "-fno-range-check" }
+! PR 52428 Read IO of integers near the end of range. Note that we
+! support the two's complement representation even though the Fortran
+! numerical model has a symmetric range. (The -fno-range-check option
+! is needed to allow the -2147483648 literal.)
+program int_range
+ implicit none
+ character(25) :: inputline = "-2147483648"
+ integer(4) :: test
+ integer :: st
+
+ read(inputline,100) test
+100 format(1i11)
+ if (test /= -2147483648) call abort
+ inputline(1:1) = " "
+ read(inputline, 100, iostat=st) test
+ if (st == 0) call abort
+ inputline(11:11) = "7"
+ read(inputline, 100) test
+ if (test /= 2147483647) call abort
+
+ ! Same as above but with list-formatted IO
+ inputline = "-2147483648"
+ read(inputline, *) test
+ if (test /= -2147483648) call abort
+ inputline(1:1) = " "
+ read(inputline, *, iostat=st) test
+ if (st == 0) call abort
+ inputline(11:11) = "7"
+ read(inputline, *) test
+ if (test /= 2147483647) call abort
+
+end program int_range