aboutsummaryrefslogtreecommitdiff
path: root/gcc/real.h
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2015-10-30 13:42:27 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2015-10-30 13:42:27 +0000
commitd5e09aa0aaec24109949afabb20b813e9096905f (patch)
treeea61f6c5d9733c823fab8c6df2bdd0114bcbfe15 /gcc/real.h
parent56517dda83af315590448610b4b6cd9d4f4d7527 (diff)
downloadgcc-d5e09aa0aaec24109949afabb20b813e9096905f.zip
gcc-d5e09aa0aaec24109949afabb20b813e9096905f.tar.gz
gcc-d5e09aa0aaec24109949afabb20b813e9096905f.tar.bz2
Robustify REAL_MODE_FORMAT
Make sure that REAL_MODE_FORMAT aborts if it is passed an invalid mode, rather than stepping beyond the bounds of an array. It turned out that some code was passing non-float modes to the real.h routines. Tested on x86_64-linux-gnu, arm-linux-gnueabi and aarch64-linux-gnu. gcc/ * real.h (REAL_MODE_FORMAT): Abort if the mode isn't a SCALAR_FLOAT_MODE_P. From-SVN: r229579
Diffstat (limited to 'gcc/real.h')
-rw-r--r--gcc/real.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/real.h b/gcc/real.h
index e65b526..d3b14e5 100644
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -167,7 +167,9 @@ extern const struct real_format *
(real_format_for_mode[DECIMAL_FLOAT_MODE_P (MODE) \
? (((MODE) - MIN_MODE_DECIMAL_FLOAT) \
+ (MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1)) \
- : ((MODE) - MIN_MODE_FLOAT)])
+ : GET_MODE_CLASS (MODE) == MODE_FLOAT \
+ ? ((MODE) - MIN_MODE_FLOAT) \
+ : (gcc_unreachable (), 0)])
#define FLOAT_MODE_FORMAT(MODE) \
(REAL_MODE_FORMAT (SCALAR_FLOAT_MODE_P (MODE)? (MODE) \