From da49a7837ae5c1aba8ff5768efb4834ceefdea47 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 26 Nov 2009 17:46:16 +0000 Subject: [PATCH] trans.c (gnat_to_gnu): Set the source location of the operator on both branches of the test in the... * gcc-interface/trans.c (gnat_to_gnu) : Set the source location of the operator on both branches of the test in the generic case. From-SVN: r154677 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/gcc-interface/trans.c | 34 ++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 001d5a8b6aa..67f80114e51 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2009-11-26 Eric Botcazou + + * gcc-interface/trans.c (gnat_to_gnu) : Set the source location + of the operator on both branches of the test in the generic case. + 2009-11-25 Eric Botcazou * gcc-interface/trans.c (unchecked_conversion_lhs_nop): Rename into... diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 5e568a2447c..d14305e42f0 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -4196,13 +4196,12 @@ gnat_to_gnu (Node_Id gnat_node) case N_In: case N_Not_In: { - tree gnu_object = gnat_to_gnu (Left_Opnd (gnat_node)); + tree gnu_obj = gnat_to_gnu (Left_Opnd (gnat_node)); Node_Id gnat_range = Right_Opnd (gnat_node); - tree gnu_low; - tree gnu_high; + tree gnu_low, gnu_high; - /* GNAT_RANGE is either an N_Range node or an identifier - denoting a subtype. */ + /* GNAT_RANGE is either an N_Range node or an identifier denoting a + subtype. */ if (Nkind (gnat_range) == N_Range) { gnu_low = gnat_to_gnu (Low_Bound (gnat_range)); @@ -4221,21 +4220,24 @@ gnat_to_gnu (Node_Id gnat_node) gnu_result_type = get_unpadded_type (Etype (gnat_node)); - /* If LOW and HIGH are identical, perform an equality test. - Otherwise, ensure that GNU_OBJECT is only evaluated once - and perform a full range test. */ + /* If LOW and HIGH are identical, perform an equality test. Otherwise, + ensure that GNU_OBJ is evaluated only once and perform a full range + test. */ if (operand_equal_p (gnu_low, gnu_high, 0)) - gnu_result = build_binary_op (EQ_EXPR, gnu_result_type, - gnu_object, gnu_low); + gnu_result + = build_binary_op (EQ_EXPR, gnu_result_type, gnu_obj, gnu_low); else { - gnu_object = protect_multiple_eval (gnu_object); + tree t1, t2; + gnu_obj = protect_multiple_eval (gnu_obj); + t1 = build_binary_op (GE_EXPR, gnu_result_type, gnu_obj, gnu_low); + if (EXPR_P (t1)) + set_expr_location_from_node (t1, gnat_node); + t2 = build_binary_op (LE_EXPR, gnu_result_type, gnu_obj, gnu_high); + if (EXPR_P (t2)) + set_expr_location_from_node (t2, gnat_node); gnu_result - = build_binary_op (TRUTH_ANDIF_EXPR, gnu_result_type, - build_binary_op (GE_EXPR, gnu_result_type, - gnu_object, gnu_low), - build_binary_op (LE_EXPR, gnu_result_type, - gnu_object, gnu_high)); + = build_binary_op (TRUTH_ANDIF_EXPR, gnu_result_type, t1, t2); } if (kind == N_Not_In) -- 2.30.2