aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog23
-rw-r--r--gcc/ada/gcc-interface/decl.c4
-rw-r--r--gcc/ada/gcc-interface/gigi.h15
-rw-r--r--gcc/ada/gcc-interface/trans.c45
-rw-r--r--gcc/ada/gcc-interface/utils2.c117
5 files changed, 94 insertions, 110 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 259677a..ca59e25 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,28 @@
2011-09-11 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/gigi.h (build_call_0_expr): Delete.
+ (build_call_1_expr): Likewise.
+ (build_call_2_expr): Likewise.
+ (build_call_n_expr): New prototype.
+ * gcc-interface/decl.c (gnat_to_gnu_entity): Use build_call_n_expr.
+ * gcc-interface/trans.c (establish_gnat_vms_condition_handler): Ditto.
+ (Handled_Sequence_Of_Statements_to_gnu): Likewise.
+ (Exception_Handler_to_gnu_zcx): Likewise.
+ (gnat_to_gnu): Likewise.
+ (build_binary_op_trapv): Likewise.
+ * gcc-interface/utils2.c (build_call_0_expr): Delete.
+ (build_call_1_expr): Likewise.
+ (build_call_2_expr): Likewise.
+ (build_call_n_expr): New function.
+ (build_call_raise): Use build_call_n_expr.
+ (build_call_raise_range): Likewise.
+ (build_call_raise_column): Likewise.
+ (build_call_alloc_dealloc_proc): Likewise.
+ (maybe_wrap_malloc): Likewise.
+ (maybe_wrap_free): Likewise.
+
+2011-09-11 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/trans.c (build_return_expr): Use void_type_node for
MODIFY_EXPR.
* gcc-interface/utils2.c (build_binary_op) <MODIFY_EXPR>: Assert that
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 54903cf..539c262 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -1492,8 +1492,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
|| (flag_stack_check == GENERIC_STACK_CHECK
&& compare_tree_int (DECL_SIZE_UNIT (gnu_decl),
STACK_CHECK_MAX_VAR_SIZE) > 0)))
- add_stmt_with_node (build_call_1_expr
- (update_setjmp_buf_decl,
+ add_stmt_with_node (build_call_n_expr
+ (update_setjmp_buf_decl, 1,
build_unary_op (ADDR_EXPR, NULL_TREE,
get_block_jmpbuf_decl ())),
gnat_entity);
diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index dbe2dc4..2614eb2 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -813,16 +813,11 @@ extern tree build_cond_expr (tree result_type, tree condition_operand,
extern tree build_compound_expr (tree result_type, tree stmt_operand,
tree expr_operand);
-/* Build a CALL_EXPR to call FUNDECL with one argument, ARG. Return
- the CALL_EXPR. */
-extern tree build_call_1_expr (tree fundecl, tree arg);
-
-/* Build a CALL_EXPR to call FUNDECL with two argument, ARG1 & ARG2. Return
- the CALL_EXPR. */
-extern tree build_call_2_expr (tree fundecl, tree arg1, tree arg2);
-
-/* Likewise to call FUNDECL with no arguments. */
-extern tree build_call_0_expr (tree fundecl);
+/* Conveniently construct a function call expression. FNDECL names the
+ function to be called, N is the number of arguments, and the "..."
+ parameters are the argument expressions. Unlike build_call_expr
+ this doesn't fold the call, hence it will always return a CALL_EXPR. */
+extern tree build_call_n_expr (tree fndecl, int n, ...);
/* Call a function that raises an exception and pass the line number and file
name, if requested. MSG says which exception function to call.
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index b831918..75f9d70 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -2444,7 +2444,7 @@ establish_gnat_vms_condition_handler (void)
return;
establish_stmt
- = build_call_1_expr (vms_builtin_establish_handler_decl,
+ = build_call_n_expr (vms_builtin_establish_handler_decl, 1,
build_unary_op
(ADDR_EXPR, NULL_TREE,
gnat_vms_condition_handler_decl));
@@ -3528,11 +3528,11 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
the setjmp buf known for any decls in this block. */
if (setjmp_longjmp)
{
- gnu_jmpsave_decl = create_var_decl (get_identifier ("JMPBUF_SAVE"),
- NULL_TREE, jmpbuf_ptr_type,
- build_call_0_expr (get_jmpbuf_decl),
- false, false, false, false,
- NULL, gnat_node);
+ gnu_jmpsave_decl
+ = create_var_decl (get_identifier ("JMPBUF_SAVE"), NULL_TREE,
+ jmpbuf_ptr_type,
+ build_call_n_expr (get_jmpbuf_decl, 0),
+ false, false, false, false, NULL, gnat_node);
DECL_ARTIFICIAL (gnu_jmpsave_decl) = 1;
/* The __builtin_setjmp receivers will immediately reinstall it. Now
@@ -3540,16 +3540,17 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
might be forward edges going to __builtin_setjmp receivers on which
it is uninitialized, although they will never be actually taken. */
TREE_NO_WARNING (gnu_jmpsave_decl) = 1;
- gnu_jmpbuf_decl = create_var_decl (get_identifier ("JMP_BUF"),
- NULL_TREE, jmpbuf_type, NULL_TREE,
- false, false, false, false,
- NULL, gnat_node);
+ gnu_jmpbuf_decl
+ = create_var_decl (get_identifier ("JMP_BUF"), NULL_TREE,
+ jmpbuf_type,
+ NULL_TREE,
+ false, false, false, false, NULL, gnat_node);
DECL_ARTIFICIAL (gnu_jmpbuf_decl) = 1;
set_block_jmpbuf_decl (gnu_jmpbuf_decl);
/* When we exit this block, restore the saved value. */
- add_cleanup (build_call_1_expr (set_jmpbuf_decl, gnu_jmpsave_decl),
+ add_cleanup (build_call_n_expr (set_jmpbuf_decl, 1, gnu_jmpsave_decl),
End_Label (gnat_node));
}
@@ -3557,7 +3558,7 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
to the binding level we made above. Note that add_cleanup is FIFO
so we must register this cleanup after the EH cleanup just above. */
if (at_end)
- add_cleanup (build_call_0_expr (gnat_to_gnu (At_End_Proc (gnat_node))),
+ add_cleanup (build_call_n_expr (gnat_to_gnu (At_End_Proc (gnat_node)), 0),
End_Label (gnat_node));
/* Now build the tree for the declarations and statements inside this block.
@@ -3565,7 +3566,7 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
start_stmt_group ();
if (setjmp_longjmp)
- add_stmt (build_call_1_expr (set_jmpbuf_decl,
+ add_stmt (build_call_n_expr (set_jmpbuf_decl, 1,
build_unary_op (ADDR_EXPR, NULL_TREE,
gnu_jmpbuf_decl)));
@@ -3596,7 +3597,7 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
VEC_safe_push (tree, gc, gnu_except_ptr_stack,
create_var_decl (get_identifier ("EXCEPT_PTR"), NULL_TREE,
build_pointer_type (except_type_node),
- build_call_0_expr (get_excptr_decl),
+ build_call_n_expr (get_excptr_decl, 0),
false, false, false, false,
NULL, gnat_node));
@@ -3621,7 +3622,7 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
/* If none of the exception handlers did anything, re-raise but do not
defer abortion. */
- gnu_expr = build_call_1_expr (raise_nodefer_decl,
+ gnu_expr = build_call_n_expr (raise_nodefer_decl, 1,
VEC_last (tree, gnu_except_ptr_stack));
set_expr_location_from_node
(gnu_expr,
@@ -3641,7 +3642,7 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
/* If the setjmp returns 1, we restore our incoming longjmp value and
then check the handlers. */
start_stmt_group ();
- add_stmt_with_node (build_call_1_expr (set_jmpbuf_decl,
+ add_stmt_with_node (build_call_n_expr (set_jmpbuf_decl, 1,
gnu_jmpsave_decl),
gnat_node);
add_stmt (gnu_handler);
@@ -3649,8 +3650,8 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
/* This block is now "if (setjmp) ... <handlers> else <block>". */
gnu_result = build3 (COND_EXPR, void_type_node,
- (build_call_1_expr
- (setjmp_decl,
+ (build_call_n_expr
+ (setjmp_decl, 1,
build_unary_op (ADDR_EXPR, NULL_TREE,
gnu_jmpbuf_decl))),
gnu_handler, gnu_inner_block);
@@ -3861,11 +3862,11 @@ Exception_Handler_to_gnu_zcx (Node_Id gnat_node)
false, false, false, false,
NULL, gnat_node);
- add_stmt_with_node (build_call_1_expr (begin_handler_decl,
+ add_stmt_with_node (build_call_n_expr (begin_handler_decl, 1,
gnu_incoming_exc_ptr),
gnat_node);
/* ??? We don't seem to have an End_Label at hand to set the location. */
- add_cleanup (build_call_1_expr (end_handler_decl, gnu_incoming_exc_ptr),
+ add_cleanup (build_call_n_expr (end_handler_decl, 1, gnu_incoming_exc_ptr),
Empty);
add_stmt_list (Statements (gnat_node));
gnat_poplevel ();
@@ -5496,7 +5497,7 @@ gnat_to_gnu (Node_Id gnat_node)
add_stmt (build_binary_op (MODIFY_EXPR, NULL_TREE, gnu_incoming_exc_ptr,
convert (ptr_type_node, integer_zero_node)));
- add_stmt (build_call_1_expr (reraise_zcx_decl, gnu_expr));
+ add_stmt (build_call_n_expr (reraise_zcx_decl, 1, gnu_expr));
gnat_poplevel ();
gnu_result = end_stmt_group ();
break;
@@ -6976,7 +6977,7 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left,
{
tree int_64 = gnat_type_for_size (64, 0);
- return convert (gnu_type, build_call_2_expr (mulv64_decl,
+ return convert (gnu_type, build_call_n_expr (mulv64_decl, 2,
convert (int_64, lhs),
convert (int_64, rhs)));
}
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index 977f881..424a0c0 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -1409,43 +1409,22 @@ build_compound_expr (tree result_type, tree stmt_operand, tree expr_operand)
return result;
}
-/* Build a CALL_EXPR to call FUNDECL with one argument, ARG. Return
- the CALL_EXPR. */
+/* Conveniently construct a function call expression. FNDECL names the
+ function to be called, N is the number of arguments, and the "..."
+ parameters are the argument expressions. Unlike build_call_expr
+ this doesn't fold the call, hence it will always return a CALL_EXPR. */
tree
-build_call_1_expr (tree fundecl, tree arg)
+build_call_n_expr (tree fndecl, int n, ...)
{
- tree call = build_call_nary (TREE_TYPE (TREE_TYPE (fundecl)),
- build_unary_op (ADDR_EXPR, NULL_TREE, fundecl),
- 1, arg);
- TREE_SIDE_EFFECTS (call) = 1;
- return call;
-}
-
-/* Build a CALL_EXPR to call FUNDECL with two arguments, ARG1 & ARG2. Return
- the CALL_EXPR. */
-
-tree
-build_call_2_expr (tree fundecl, tree arg1, tree arg2)
-{
- tree call = build_call_nary (TREE_TYPE (TREE_TYPE (fundecl)),
- build_unary_op (ADDR_EXPR, NULL_TREE, fundecl),
- 2, arg1, arg2);
- TREE_SIDE_EFFECTS (call) = 1;
- return call;
-}
-
-/* Likewise to call FUNDECL with no arguments. */
-
-tree
-build_call_0_expr (tree fundecl)
-{
- /* We rely on build_call_nary to compute TREE_SIDE_EFFECTS. This makes
- it possible to propagate DECL_IS_PURE on parameterless functions. */
- tree call = build_call_nary (TREE_TYPE (TREE_TYPE (fundecl)),
- build_unary_op (ADDR_EXPR, NULL_TREE, fundecl),
- 0);
- return call;
+ va_list ap;
+ tree fntype = TREE_TYPE (fndecl);
+ tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
+
+ va_start (ap, n);
+ fn = build_call_valist (TREE_TYPE (fntype), fn, n, ap);
+ va_end (ap);
+ return fn;
}
/* Call a function that raises an exception and pass the line number and file
@@ -1483,7 +1462,7 @@ build_call_raise (int msg, Node_Id gnat_node, char kind)
tree gnu_exception_entity
= gnat_to_gnu_entity (Get_RT_Exception_Entity (msg), NULL_TREE, 0);
tree gnu_call
- = build_call_1_expr (gnu_local_raise,
+ = build_call_n_expr (gnu_local_raise, 1,
build_unary_op (ADDR_EXPR, NULL_TREE,
gnu_exception_entity));
@@ -1513,7 +1492,7 @@ build_call_raise (int msg, Node_Id gnat_node, char kind)
build_index_type (size_int (len)));
return
- build_call_2_expr (fndecl,
+ build_call_n_expr (fndecl, 2,
build1 (ADDR_EXPR,
build_pointer_type (unsigned_char_type_node),
filename),
@@ -1528,7 +1507,6 @@ tree
build_call_raise_range (int msg, Node_Id gnat_node,
tree index, tree first, tree last)
{
- tree call;
tree fndecl = gnat_raise_decls_ext[msg];
tree filename;
int line_number, column_number;
@@ -1561,19 +1539,16 @@ build_call_raise_range (int msg, Node_Id gnat_node,
TREE_TYPE (filename) = build_array_type (unsigned_char_type_node,
build_index_type (size_int (len)));
- call = build_call_nary (TREE_TYPE (TREE_TYPE (fndecl)),
- build_unary_op (ADDR_EXPR, NULL_TREE, fndecl),
- 6,
- build1 (ADDR_EXPR,
- build_pointer_type (unsigned_char_type_node),
- filename),
- build_int_cst (NULL_TREE, line_number),
- build_int_cst (NULL_TREE, column_number),
- convert (integer_type_node, index),
- convert (integer_type_node, first),
- convert (integer_type_node, last));
- TREE_SIDE_EFFECTS (call) = 1;
- return call;
+ return
+ build_call_n_expr (fndecl, 6,
+ build1 (ADDR_EXPR,
+ build_pointer_type (unsigned_char_type_node),
+ filename),
+ build_int_cst (NULL_TREE, line_number),
+ build_int_cst (NULL_TREE, column_number),
+ convert (integer_type_node, index),
+ convert (integer_type_node, first),
+ convert (integer_type_node, last));
}
/* Similar to build_call_raise, with extra information about the column
@@ -1583,7 +1558,6 @@ tree
build_call_raise_column (int msg, Node_Id gnat_node)
{
tree fndecl = gnat_raise_decls_ext[msg];
- tree call;
tree filename;
int line_number, column_number;
const char *str;
@@ -1615,16 +1589,13 @@ build_call_raise_column (int msg, Node_Id gnat_node)
TREE_TYPE (filename) = build_array_type (unsigned_char_type_node,
build_index_type (size_int (len)));
- call = build_call_nary (TREE_TYPE (TREE_TYPE (fndecl)),
- build_unary_op (ADDR_EXPR, NULL_TREE, fndecl),
- 3,
- build1 (ADDR_EXPR,
- build_pointer_type (unsigned_char_type_node),
- filename),
- build_int_cst (NULL_TREE, line_number),
- build_int_cst (NULL_TREE, column_number));
- TREE_SIDE_EFFECTS (call) = 1;
- return call;
+ return
+ build_call_n_expr (fndecl, 3,
+ build1 (ADDR_EXPR,
+ build_pointer_type (unsigned_char_type_node),
+ filename),
+ build_int_cst (NULL_TREE, line_number),
+ build_int_cst (NULL_TREE, column_number));
}
/* qsort comparer for the bit positions of two constructor elements
@@ -1842,7 +1813,6 @@ build_call_alloc_dealloc_proc (tree gnu_obj, tree gnu_size, tree gnu_type,
Entity_Id gnat_proc, Entity_Id gnat_pool)
{
tree gnu_proc = gnat_to_gnu (gnat_proc);
- tree gnu_proc_addr = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_proc);
tree gnu_call;
/* The storage pools are obviously always tagged types, but the
@@ -1866,13 +1836,11 @@ build_call_alloc_dealloc_proc (tree gnu_obj, tree gnu_size, tree gnu_type,
comes the address of the object, for a deallocator, then the
size and alignment. */
if (gnu_obj)
- gnu_call = build_call_nary (TREE_TYPE (TREE_TYPE (gnu_proc)),
- gnu_proc_addr, 4, gnu_pool_addr,
- gnu_obj, gnu_size, gnu_align);
+ gnu_call = build_call_n_expr (gnu_proc, 4, gnu_pool_addr, gnu_obj,
+ gnu_size, gnu_align);
else
- gnu_call = build_call_nary (TREE_TYPE (TREE_TYPE (gnu_proc)),
- gnu_proc_addr, 3, gnu_pool_addr,
- gnu_size, gnu_align);
+ gnu_call = build_call_n_expr (gnu_proc, 3, gnu_pool_addr,
+ gnu_size, gnu_align);
}
/* Secondary stack case. */
@@ -1888,14 +1856,11 @@ build_call_alloc_dealloc_proc (tree gnu_obj, tree gnu_size, tree gnu_type,
/* The first arg is the address of the object, for a deallocator,
then the size. */
if (gnu_obj)
- gnu_call = build_call_nary (TREE_TYPE (TREE_TYPE (gnu_proc)),
- gnu_proc_addr, 2, gnu_obj, gnu_size);
+ gnu_call = build_call_n_expr (gnu_proc, 2, gnu_obj, gnu_size);
else
- gnu_call = build_call_nary (TREE_TYPE (TREE_TYPE (gnu_proc)),
- gnu_proc_addr, 1, gnu_size);
+ gnu_call = build_call_n_expr (gnu_proc, 1, gnu_size);
}
- TREE_SIDE_EFFECTS (gnu_call) = 1;
return gnu_call;
}
@@ -1935,9 +1900,9 @@ maybe_wrap_malloc (tree data_size, tree data_type, Node_Id gnat_node)
&& Nkind (gnat_node) == N_Allocator
&& (UI_To_Int (Esize (Etype (gnat_node))) == 32
|| Convention (Etype (gnat_node)) == Convention_C))
- malloc_ptr = build_call_1_expr (malloc32_decl, size_to_malloc);
+ malloc_ptr = build_call_n_expr (malloc32_decl, 1, size_to_malloc);
else
- malloc_ptr = build_call_1_expr (malloc_decl, size_to_malloc);
+ malloc_ptr = build_call_n_expr (malloc_decl, 1, size_to_malloc);
if (aligning_type)
{
@@ -2016,7 +1981,7 @@ maybe_wrap_free (tree data_ptr, tree data_type)
else
free_ptr = data_ptr;
- return build_call_1_expr (free_decl, free_ptr);
+ return build_call_n_expr (free_decl, 1, free_ptr);
}
/* Build a GCC tree to call an allocation or deallocation function.