- gnu_expr_type = get_base_type (TREE_TYPE (gnu_expr_l));
-
- /* Build a compound expression that does the range checks and
- returns the low bound. */
- gnu_expr = build_binary_op (COMPOUND_EXPR, gnu_expr_type,
- convert (gnu_expr_type, gnu_expr_h),
- convert (gnu_expr_type, gnu_expr_l));
-
- /* Build a conditional expression that does the range check and
+ gnu_expr_type = get_base_type (TREE_TYPE (gnu_index_type));
+
+ /* Test whether the minimum slice value is too small. */
+ gnu_expr_l = build_binary_op (LT_EXPR, integer_type_node,
+ convert (gnu_expr_type,
+ gnu_min_expr),
+ convert (gnu_expr_type,
+ gnu_base_min_expr));
+
+ /* Test whether the maximum slice value is too large. */
+ gnu_expr_h = build_binary_op (GT_EXPR, integer_type_node,
+ convert (gnu_expr_type,
+ gnu_max_expr),
+ convert (gnu_expr_type,
+ gnu_base_max_expr));
+
+ /* Build a slice index check that returns the low bound,
+ assuming the slice is not empty. */
+ gnu_expr = emit_check
+ (build_binary_op (TRUTH_ORIF_EXPR, integer_type_node,
+ gnu_expr_l, gnu_expr_h),
+ gnu_min_expr, CE_Index_Check_Failed);
+
+ /* Build a conditional expression that does the index checks and