aboutsummaryrefslogtreecommitdiff
path: root/gcc/f/com.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2002-10-30 23:07:48 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2002-10-30 23:07:48 +0000
commit9402f6fb7450c77691ef079abae90b2130a65117 (patch)
treed3d4b7bca2e8518146b0b70b1283cd27604f517d /gcc/f/com.c
parent9b5b7e3a8fe143a9b1be4cfdb17fccc1e5ae58ff (diff)
downloadgcc-9402f6fb7450c77691ef079abae90b2130a65117.zip
gcc-9402f6fb7450c77691ef079abae90b2130a65117.tar.gz
gcc-9402f6fb7450c77691ef079abae90b2130a65117.tar.bz2
fold-const.c (fold_binary_op_with_conditional_arg): Improve handling of cases where one or both branches of the conditional have...
* fold-const.c (fold_binary_op_with_conditional_arg): Improve handling of cases where one or both branches of the conditional have void type, i.e. throw an exception or don't return. (fold): Only apply (and undo) type conversion to the non-void branches of a COND_EXPR. * f/com.c (ffecom_subscript_check_): Cast the failure branch of the bounds check COND_EXPR to void, to indicate noreturn. (ffe_truthvalue_conversion): Only apply truth value conversion to the non-void branches of a COND_EXPR. From-SVN: r58661
Diffstat (limited to 'gcc/f/com.c')
-rw-r--r--gcc/f/com.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/f/com.c b/gcc/f/com.c
index cc3af7e..1e066f5 100644
--- a/gcc/f/com.c
+++ b/gcc/f/com.c
@@ -806,6 +806,7 @@ ffecom_subscript_check_ (tree array, tree element, int dim, int total_dims,
die = ffecom_call_gfrt (FFECOM_gfrtRANGE,
args, NULL_TREE);
TREE_SIDE_EFFECTS (die) = 1;
+ die = convert (void_type_node, die);
element = ffecom_3 (COND_EXPR,
TREE_TYPE (element),
@@ -14772,10 +14773,17 @@ ffe_truthvalue_conversion (expr)
return ffe_truthvalue_conversion (TREE_OPERAND (expr, 0));
case COND_EXPR:
- /* Distribute the conversion into the arms of a COND_EXPR. */
- return fold (build (COND_EXPR, integer_type_node, TREE_OPERAND (expr, 0),
- ffe_truthvalue_conversion (TREE_OPERAND (expr, 1)),
- ffe_truthvalue_conversion (TREE_OPERAND (expr, 2))));
+ {
+ /* Distribute the conversion into the arms of a COND_EXPR. */
+ tree arg1 = TREE_OPERAND (expr, 1);
+ tree arg2 = TREE_OPERAND (expr, 2);
+ if (! VOID_TYPE_P (TREE_TYPE (arg1)))
+ arg1 = ffe_truthvalue_conversion (arg1);
+ if (! VOID_TYPE_P (TREE_TYPE (arg2)))
+ arg2 = ffe_truthvalue_conversion (arg2);
+ return fold (build (COND_EXPR, integer_type_node,
+ TREE_OPERAND (expr, 0), arg1, arg2));
+ }
case CONVERT_EXPR:
/* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,