r278684 - in /trunk/gcc: ChangeLog builtin-type...

jsm28@gcc.gnu.org jsm28@gcc.gnu.org
Mon Nov 25 13:45:00 GMT 2019


Author: jsm28
Date: Mon Nov 25 13:45:42 2019
New Revision: 278684

URL: https://gcc.gnu.org/viewcvs?rev=278684&root=gcc&view=rev
Log:
Prevent all uses of DFP when unsupported (PR c/91985).

Code that directly uses _Decimal* types on architectures not
supporting DFP is properly diagnosed ("error: decimal floating-point
not supported for this target"), via a call to
targetm.decimal_float_supported_p, if the _Decimal32, _Decimal64 or
_Decimal128 keywords are used to access it.  Use via mode attributes
is also diagnosed ("unable to emulate 'SD'"); so is use of the
FLOAT_CONST_DECIMAL64 pragma.  However, it is possible to access those
types via typeof applied to constants or built-in functions without
such an error.  I expect that there are ways to get an ICE from this;
certainly it uses a completely undefined ABI.

This patch arranges for the types not to exist in the compiler at all
when DFP is not supported.  As is done with unsupported _FloatN /
_FloatNx types, the global tree nodes are left as NULL_TREE, and the
built-in function machinery is made to use error_mark_node for them in
that case in builtin-types.def, so that the built-in functions are
unavailable.  Code handling constants is adjusted to give an error,
and other code that might not work with the global tree nodes being
NULL_TREE is also updated.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.  Also tested
with no regressions for cross to aarch64-linux-gnu, as a configuration
without DFP support.

	PR c/91985
gcc:
	* builtin-types.def (BT_DFLOAT32, BT_DFLOAT64, BT_DFLOAT128)
	(BT_DFLOAT32_PTR, BT_DFLOAT64_PTR, BT_DFLOAT128_PTR): Define to
	error_mark_node if corresponding global tree node is NULL.
	* tree.c (build_common_tree_nodes): Do not initialize
	dfloat32_type_node, dfloat64_type_node or dfloat128_type_node if
	decimal floating-point not supported.

gcc/c:
	* c-decl.c (finish_declspecs): Use int instead of decimal
	floating-point types if decimal floating-point not supported.

gcc/c-family:
	* c-common.c (c_common_type_for_mode): Handle decimal
	floating-point types being NULL_TREE.
	* c-format.c (get_format_for_type_1): Handle specified types being
	NULL_TREE.
	* c-lex.c (interpret_float): Give an error for decimal
	floating-point constants when decimal floating-point not
	supported.

gcc/lto:
	* lto-lang.c (lto_type_for_mode): Handle decimal floating-point
	types being NULL_TREE.

gcc/testsuite:
	* gcc.dg/c2x-no-dfp-1.c, gcc.dg/gnu2x-builtins-no-dfp-1.c: New
	tests.
	* gcc.dg/fltconst-pedantic-dfp.c: Expect errors when decimal
	floating-point not supported.

Added:
    trunk/gcc/testsuite/gcc.dg/c2x-no-dfp-1.c
    trunk/gcc/testsuite/gcc.dg/gnu2x-builtins-no-dfp-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtin-types.def
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/c-family/c-format.c
    trunk/gcc/c-family/c-lex.c
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/lto/ChangeLog
    trunk/gcc/lto/lto-lang.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/fltconst-pedantic-dfp.c
    trunk/gcc/tree.c



More information about the Gcc-cvs mailing list