Skip to content
Snippets Groups Projects
Commit 16ec2670 authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

c++: Excess precision for ? int : float or int == float [PR107097, PR82071, PR87390]

The following incremental patch implements the C11 behavior (for all C++
versions) for
cond ? int : float
cond ? float : int
int cmp float
float cmp int
where int is any integral type, float any floating point type with
excess precision and cmp ==, !=, >, <, >=, <= and <=>.

2022-10-14  Jakub Jelinek  <jakub@redhat.com>

	PR c/82071
	PR c/87390
	PR c++/107097
gcc/cp/
	* cp-tree.h (cp_ep_convert_and_check): Remove.
	* cvt.cc (cp_ep_convert_and_check): Remove.
	* call.cc (build_conditional_expr): Use excess precision for ?: with
	one arm floating and another integral.  Don't convert first to
	semantic result type from integral types.
	(convert_like_internal): Don't call cp_ep_convert_and_check, instead
	just strip EXCESS_PRECISION_EXPR before calling cp_convert_and_check
	or cp_convert.
	* typeck.cc (cp_build_binary_op): Set may_need_excess_precision
	for comparisons or SPACESHIP_EXPR with at least one operand integral.
	Don't compute semantic_result_type if build_type is non-NULL.  Call
	cp_convert_and_check instead of cp_ep_convert_and_check.
gcc/testsuite/
	* gcc.target/i386/excess-precision-8.c: For C++ wrap abort and
	exit declarations into extern "C" block.
	* gcc.target/i386/excess-precision-10.c: Likewise.
	* g++.target/i386/excess-precision-7.C: Remove.
	* g++.target/i386/excess-precision-8.C: New test.
	* g++.target/i386/excess-precision-9.C: Remove.
	* g++.target/i386/excess-precision-10.C: New test.
	* g++.target/i386/excess-precision-12.C: New test.
parent 98e34113
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