diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-24 05:52:44 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-24 05:52:44 +0000 |
commit | c086aee152958250310d4f5ea3df854436c764fa (patch) | |
tree | 977427f50ee91accd2a6424d4d19533a4274a057 /libgfortran | |
parent | ad4ce1d1a273c7509109ecfaa31beacbe4e071d6 (diff) | |
download | gcc-c086aee152958250310d4f5ea3df854436c764fa.tar.gz |
2007-07-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/30814
* trans-decl.c (generate_function_code): Add argument
for flag_bounds_check to the array for set_options.
* invoke.texi: Mention that some checks require
-fbounds-check to be set during compilation of the
main program.
2007-07-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/30814
* libgfortran.h: Add bounds_check to compile_options_t.
* runtime/compile_options.c (set_options): Add handling
of compile_options.bounds_check.
* intrinsics/pack_generic.c (pack_internal): Also determine
the number of elements if compile_options.bounds_check is
true. Raise runtime error if a different array shape is
detected.
2007-07-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/30814
* gfortran.dg/pack_bounds_1.f90: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126866 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 11 | ||||
-rw-r--r-- | libgfortran/intrinsics/pack_generic.c | 39 | ||||
-rw-r--r-- | libgfortran/runtime/compile_options.c | 2 |
3 files changed, 38 insertions, 14 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index ae9d6b0aa88..658d702668f 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,14 @@ +2007-07-24 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/30814 + * libgfortran.h: Add bounds_check to compile_options_t. + * runtime/compile_options.c (set_options): Add handling + of compile_options.bounds_check. + * intrinsics/pack_generic.c (pack_internal): Also determine + the number of elements if compile_options.bounds_check is + true. Raise runtime error if a different array shape is + detected. + 2007-07-23 Christopher D. Rickett <crickett@lanl.gov> PR fortran/32600 diff --git a/libgfortran/intrinsics/pack_generic.c b/libgfortran/intrinsics/pack_generic.c index 06e70844bf0..104c59f6e4d 100644 --- a/libgfortran/intrinsics/pack_generic.c +++ b/libgfortran/intrinsics/pack_generic.c @@ -97,6 +97,7 @@ pack_internal (gfc_array_char *ret, const gfc_array_char *array, index_type n; index_type dim; index_type nelem; + index_type total; dim = GFC_DESCRIPTOR_RANK (array); zero_sized = 0; @@ -127,10 +128,10 @@ pack_internal (gfc_array_char *ret, const gfc_array_char *array, mptr = GFOR_POINTER_L8_TO_L4 (mptr); } - if (ret->data == NULL) + if (ret->data == NULL || compile_options.bounds_check) { - /* Allocate the memory for the result. */ - int total; + /* Count the elements, either for allocating memory or + for bounds checking. */ if (vector != NULL) { @@ -196,20 +197,30 @@ pack_internal (gfc_array_char *ret, const gfc_array_char *array, } } - /* Setup the array descriptor. */ - ret->dim[0].lbound = 0; - ret->dim[0].ubound = total - 1; - ret->dim[0].stride = 1; + if (ret->data == NULL) + { + /* Setup the array descriptor. */ + ret->dim[0].lbound = 0; + ret->dim[0].ubound = total - 1; + ret->dim[0].stride = 1; - ret->offset = 0; - if (total == 0) + ret->offset = 0; + if (total == 0) + { + /* In this case, nothing remains to be done. */ + ret->data = internal_malloc_size (1); + return; + } + else + ret->data = internal_malloc_size (size * total); + } + else { - /* In this case, nothing remains to be done. */ - ret->data = internal_malloc_size (1); - return; + /* We come here because of range checking. */ + if (total != ret->dim[0].ubound + 1 - ret->dim[0].lbound) + runtime_error ("Incorrect extent in return value of" + " PACK intrinsic"); } - else - ret->data = internal_malloc_size (size * total); } rstride0 = ret->dim[0].stride * size; diff --git a/libgfortran/runtime/compile_options.c b/libgfortran/runtime/compile_options.c index 0976a39eade..a6e2a42229e 100644 --- a/libgfortran/runtime/compile_options.c +++ b/libgfortran/runtime/compile_options.c @@ -54,6 +54,8 @@ set_options (int num, int options[]) compile_options.backtrace = options[4]; if (num >= 6) compile_options.sign_zero = options[5]; + if (num >= 7) + compile_options.bounds_check = options[6]; } |