diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2016-01-18 11:29:00 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2016-01-18 11:29:00 +0000 |
commit | 9a1bdc314ba086904861838838bc2e0743476dcd (patch) | |
tree | 9b5a32fc16b8443b82e93e51c4c082d86cb64a11 /gcc/ada/gcc-interface/utils2.c | |
parent | f5460595a488ce9c131815016d0c89dc0d17ca14 (diff) | |
download | gcc-9a1bdc314ba086904861838838bc2e0743476dcd.zip gcc-9a1bdc314ba086904861838838bc2e0743476dcd.tar.gz gcc-9a1bdc314ba086904861838838bc2e0743476dcd.tar.bz2 |
gigi.h (build_call_raise_column): Adjust prototype.
* gcc-interface/gigi.h (build_call_raise_column): Adjust prototype.
(build_call_raise_range): Likewise.
(gnat_unsigned_type): Delete.
(gnat_signed_type): Likewise.
(gnat_signed_or_unsigned_type_for): New prototype.
(gnat_unsigned_type_for): New inline function.
(gnat_signed_type_for): Likewise.
* gcc-interface/cuintp.c (build_cst_from_int): Call build_int_cst.
* gcc-interface/decl.c (gnat_to_gnu_entity): Likewise.
(gnat_to_gnu_entity) <E_Array_Type>: Always translate the index types
and compute their base type from that.
<E_Array_Subtype>: Remove duplicate declaration.
* gcc-interface/misc.c (get_array_bit_stride): Call build_int_cst.
* gcc-interface/trans.c (get_type_length): Likewise.
(Attribute_to_gnu): Likewise.
(Loop_Statement_to_gnu): Likewise.
(Call_to_gnu): Likewise.
(gnat_to_gnu): Call build_real, build_int_cst, gnat_unsigned_type_for
and gnat_signed_type_for. Minor tweaks.
(build_binary_op_trapv): Likewise.
(emit_check): Likewise.
(convert_with_check): Likewise.
(Raise_Error_to_gnu): Adjust calls to the build_call_raise family of
functions. Minor tweaks.
(Case_Statement_to_gnu): Remove dead code.
(gnat_to_gnu): Call gnat_unsigned_type_for and gnat_signed_type_for.
(init_code_table): Minor reordering.
* gcc-interface/utils.c (gnat_unsigned_type): Delete.
(gnat_signed_type): Likewise.
(gnat_signed_or_unsigned_type_for): New function.
(unchecked_convert): Use directly the size in the test for precision
vs size adjustments.
(install_builtin_elementary_types): Call gnat_signed_type_for.
* gcc-interface/utils2.c (nonbinary_modular_operation): Call
build_int_cst.
(build_goto_raise): New function taken from...
(build_call_raise): ...here. Call it.
(build_call_raise_column): Add KIND parameter and call it.
(build_call_raise_range): Likewise.
From-SVN: r232503
Diffstat (limited to 'gcc/ada/gcc-interface/utils2.c')
-rw-r--r-- | gcc/ada/gcc-interface/utils2.c | 76 |
1 files changed, 45 insertions, 31 deletions
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 803a243..efeb147 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -592,7 +592,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs, result = gnat_protect_expr (result); result = fold_build3 (COND_EXPR, op_type, fold_build2 (LT_EXPR, boolean_type_node, result, - convert (op_type, integer_zero_node)), + build_int_cst (op_type, 0)), fold_build2 (PLUS_EXPR, op_type, result, modulus), result); } @@ -1601,8 +1601,8 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) { if (integer_pow2p (fold_build2 (PLUS_EXPR, operation_type, modulus, - convert (operation_type, - integer_one_node)))) + build_int_cst (operation_type, + 1)))) result = fold_build2 (BIT_XOR_EXPR, operation_type, operand, modulus); else @@ -1613,9 +1613,8 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) fold_build2 (NE_EXPR, boolean_type_node, operand, - convert - (operation_type, - integer_zero_node)), + build_int_cst + (operation_type, 0)), result, operand); } else @@ -1626,8 +1625,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) that constant for nonbinary modulus. */ tree cnst = fold_build2 (MINUS_EXPR, operation_type, modulus, - convert (operation_type, - integer_one_node)); + build_int_cst (operation_type, 1)); if (mod_pow2) result = fold_build2 (BIT_XOR_EXPR, operation_type, @@ -1748,6 +1746,32 @@ build_call_n_expr (tree fndecl, int n, ...) return fn; } +/* Build a goto to LABEL for a raise, with an optional call to Local_Raise. + MSG gives the exception's identity for the call to Local_Raise, if any. */ + +static tree +build_goto_raise (tree label, int msg) +{ + tree gnu_result = build1 (GOTO_EXPR, void_type_node, label); + Entity_Id local_raise = Get_Local_Raise_Call_Entity (); + + /* If Local_Raise is present, build Local_Raise (Exception'Identity). */ + if (Present (local_raise)) + { + tree gnu_local_raise = gnat_to_gnu_entity (local_raise, NULL_TREE, 0); + tree gnu_exception_entity + = gnat_to_gnu_entity (Get_RT_Exception_Entity (msg), NULL_TREE, 0); + tree gnu_call + = build_call_n_expr (gnu_local_raise, 1, + build_unary_op (ADDR_EXPR, NULL_TREE, + gnu_exception_entity)); + gnu_result + = build2 (COMPOUND_EXPR, void_type_node, gnu_call, gnu_result); + } + + return gnu_result; +} + /* Expand the SLOC of GNAT_NODE, if present, into tree location information pointed to by FILENAME, LINE and COL. Fall back to the current location if GNAT_NODE is absent or has no SLOC. */ @@ -1803,27 +1827,7 @@ build_call_raise (int msg, Node_Id gnat_node, char kind) /* If this is to be done as a goto, handle that case. */ if (label) - { - Entity_Id local_raise = Get_Local_Raise_Call_Entity (); - tree gnu_result = build1 (GOTO_EXPR, void_type_node, label); - - /* If Local_Raise is present, build Local_Raise (Exception'Identity). */ - if (Present (local_raise)) - { - tree gnu_local_raise - = gnat_to_gnu_entity (local_raise, NULL_TREE, 0); - tree gnu_exception_entity - = gnat_to_gnu_entity (Get_RT_Exception_Entity (msg), NULL_TREE, 0); - tree gnu_call - = build_call_n_expr (gnu_local_raise, 1, - build_unary_op (ADDR_EXPR, NULL_TREE, - gnu_exception_entity)); - gnu_result - = build2 (COMPOUND_EXPR, void_type_node, gnu_call, gnu_result); - } - - return gnu_result; - } + return build_goto_raise (label, msg); expand_sloc (gnat_node, &filename, &line, NULL); @@ -1839,11 +1843,16 @@ build_call_raise (int msg, Node_Id gnat_node, char kind) where the check failed. */ tree -build_call_raise_column (int msg, Node_Id gnat_node) +build_call_raise_column (int msg, Node_Id gnat_node, char kind) { tree fndecl = gnat_raise_decls_ext[msg]; + tree label = get_exception_label (kind); tree filename, line, col; + /* If this is to be done as a goto, handle that case. */ + if (label) + return build_goto_raise (label, msg); + expand_sloc (gnat_node, &filename, &line, &col); return @@ -1858,12 +1867,17 @@ build_call_raise_column (int msg, Node_Id gnat_node) with extra information of the form "INDEX out of range FIRST..LAST". */ tree -build_call_raise_range (int msg, Node_Id gnat_node, +build_call_raise_range (int msg, Node_Id gnat_node, char kind, tree index, tree first, tree last) { tree fndecl = gnat_raise_decls_ext[msg]; + tree label = get_exception_label (kind); tree filename, line, col; + /* If this is to be done as a goto, handle that case. */ + if (label) + return build_goto_raise (label, msg); + expand_sloc (gnat_node, &filename, &line, &col); return |