diff options
author | Jim Wilson <wilson@gcc.gnu.org> | 1993-08-08 14:38:20 -0700 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 1993-08-08 14:38:20 -0700 |
commit | e6d525599dddc1c7e20ebdd5a9bfd4257b15f39e (patch) | |
tree | 9268279dc1a95a42ed1951b972b215112944e66e | |
parent | 312def2eda47dd591c50f9bf9959fc3129e275e0 (diff) | |
download | gcc-e6d525599dddc1c7e20ebdd5a9bfd4257b15f39e.zip gcc-e6d525599dddc1c7e20ebdd5a9bfd4257b15f39e.tar.gz gcc-e6d525599dddc1c7e20ebdd5a9bfd4257b15f39e.tar.bz2 |
(build_array_ref): Force array to be allocated on the stack if...
(build_array_ref): Force array to be allocated on the
stack if it is accessed by out-of-bound constant integer subscript.
From-SVN: r5111
-rw-r--r-- | gcc/c-typeck.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 64d51e1..c748a56 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1252,6 +1252,17 @@ build_array_ref (array, index) if (mark_addressable (array) == 0) return error_mark_node; } + /* An array that is indexed by a constant value which is not within + the array bounds cannot be stored in a register either; because we + would get a crash in store_bit_field/extract_bit_field when trying + to access a non-existent part of the register. */ + if (TREE_CODE (index) == INTEGER_CST + && TYPE_VALUES (TREE_TYPE (array)) + && ! int_fits_type_p (index, TYPE_VALUES (TREE_TYPE (array)))) + { + if (mark_addressable (array) == 0) + return error_mark_node; + } if (pedantic && !lvalue_p (array)) { |