summaryrefslogtreecommitdiff
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-14 15:48:52 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-14 15:48:52 +0000
commit16a547ac42d850d8f2f902709e2217619e2302d2 (patch)
tree9332589b07be445c08324bf933ee5c698a12987b /gcc/c-typeck.c
parent8a91b6a6d3d03ee47bc8c845b09c92a0bac56e79 (diff)
downloadgcc-16a547ac42d850d8f2f902709e2217619e2302d2.tar.gz
PR c/45969
* c-typeck.c (build_binary_op): Don't try to compute a semantic type with excess precision for boolean operations. testsuite: * gcc.c-torture/compile/pr45969-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165472 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r--gcc/c-typeck.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 14bc281615e..fe10e8b6ded 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -9423,6 +9423,10 @@ build_binary_op (location_t location, enum tree_code code,
precision. */
bool may_need_excess_precision;
+ /* True means this is a boolean operation that converts both its
+ operands to truth-values. */
+ bool boolean_op = false;
+
if (location == UNKNOWN_LOCATION)
location = input_location;
@@ -9650,6 +9654,7 @@ build_binary_op (location_t location, enum tree_code code,
op0 = c_common_truthvalue_conversion (location, op0);
op1 = c_common_truthvalue_conversion (location, op1);
converted = 1;
+ boolean_op = true;
}
if (code == TRUTH_ANDIF_EXPR)
{
@@ -10192,7 +10197,8 @@ build_binary_op (location_t location, enum tree_code code,
if (build_type == NULL_TREE)
{
build_type = result_type;
- if (type0 != orig_type0 || type1 != orig_type1)
+ if ((type0 != orig_type0 || type1 != orig_type1)
+ && !boolean_op)
{
gcc_assert (may_need_excess_precision && common);
semantic_result_type = c_common_type (orig_type0, orig_type1);