Skip to content
Snippets Groups Projects
Commit 66337ff8 authored by Joseph Myers's avatar Joseph Myers
Browse files

c: Update checks on constexpr floating-point initializers

WG14 has agreed some changes (detailed at the end of N3082) to the
rules on constexpr initializers for floating types.  Update GCC's
implementation to match: binary initializers are now allowed for
decimal types, and real initializers for complex types, but signaling
NaN initializers can't be used for a different type with the same
mode.

There are also changes to the constexpr rules for pointer types
(allowing null pointer address constants that aren't null pointer
constants), which I'll deal with separately.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
	* c-typeck.cc: Include "realmpfr.h".
	(constexpr_init_fits_real_type): Do not allow signaling NaN
	conversions to different types with the same mode.  Handle
	conversions from binary to decimal types.
	(check_constexpr_init): Do not disallow real initializers for
	complex types.  Do not disallow binary initializers for decimal
	floating types.

gcc/testsuite/
	* gcc.dg/c2x-constexpr-1.c: Test constexpr initializers of complex
	types with real initializers are allowed.
	* gcc.dg/c2x-constexpr-3.c: Do not test for constexpr initializers
	of complex types with real initializers being disallowed.
	* gcc.dg/c2x-constexpr-8.c: Add tests of signaling NaN complex
	initializers.
	* gcc.dg/c2x-constexpr-9.c: Add more tests.
	* gcc.dg/dfp/c2x-constexpr-dfp-1.c: Add tests of binary floating
	initializers for decimal types.
	* gcc.dg/dfp/c2x-constexpr-dfp-2.c: Change tests of binary
	initializers for decimal types.  Add more tests of decimal
	initializers for binary types.
parent 5c43f06c
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment