Commit d5e09aa0 by Richard Sandiford Committed by Richard Sandiford

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
parent 56517dda
2015-10-30 Richard Sandiford <richard.sandiford@arm.com>
* real.h (REAL_MODE_FORMAT): Abort if the mode isn't a
SCALAR_FLOAT_MODE_P.
2015-10-30 Alan Lawrence <alan.lawrence@arm.com> 2015-10-30 Alan Lawrence <alan.lawrence@arm.com>
* tree-sra.c (scalarizable_type_p): Comment variable-length arrays. * tree-sra.c (scalarizable_type_p): Comment variable-length arrays.
...@@ -167,7 +167,9 @@ extern const struct real_format * ...@@ -167,7 +167,9 @@ extern const struct real_format *
(real_format_for_mode[DECIMAL_FLOAT_MODE_P (MODE) \ (real_format_for_mode[DECIMAL_FLOAT_MODE_P (MODE) \
? (((MODE) - MIN_MODE_DECIMAL_FLOAT) \ ? (((MODE) - MIN_MODE_DECIMAL_FLOAT) \
+ (MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1)) \ + (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) \ #define FLOAT_MODE_FORMAT(MODE) \
(REAL_MODE_FORMAT (SCALAR_FLOAT_MODE_P (MODE)? (MODE) \ (REAL_MODE_FORMAT (SCALAR_FLOAT_MODE_P (MODE)? (MODE) \
......
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