aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c101
1 files changed, 34 insertions, 67 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index db38701..8c36149 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -428,6 +428,7 @@ build_dummy_unc_pointer_types (Entity_Id gnat_desig_type, tree gnu_desig_type)
TYPE_DUMMY_P (gnu_object_type) = 1;
TYPE_POINTER_TO (gnu_desig_type) = gnu_fat_type;
+ TYPE_REFERENCE_TO (gnu_desig_type) = gnu_fat_type;
TYPE_OBJECT_RECORD_TYPE (gnu_desig_type) = gnu_object_type;
}
@@ -2221,47 +2222,6 @@ split_plus (tree in, tree *pvar)
return bitsize_zero_node;
}
-/* Return a FUNCTION_TYPE node. RETURN_TYPE is the type returned by the
- subprogram. If it is VOID_TYPE, then we are dealing with a procedure,
- otherwise we are dealing with a function. PARAM_DECL_LIST is a list of
- PARM_DECL nodes that are the subprogram parameters. CICO_LIST is the
- copy-in/copy-out list to be stored into the TYPE_CICO_LIST field.
- RETURN_UNCONSTRAINED_P is true if the function returns an unconstrained
- object. RETURN_BY_DIRECT_REF_P is true if the function returns by direct
- reference. RETURN_BY_INVISI_REF_P is true if the function returns by
- invisible reference. */
-
-tree
-create_subprog_type (tree return_type, tree param_decl_list, tree cico_list,
- bool return_unconstrained_p, bool return_by_direct_ref_p,
- bool return_by_invisi_ref_p)
-{
- /* A list of the data type nodes of the subprogram formal parameters.
- This list is generated by traversing the input list of PARM_DECL
- nodes. */
- vec<tree, va_gc> *param_type_list = NULL;
- tree t, type;
-
- for (t = param_decl_list; t; t = DECL_CHAIN (t))
- vec_safe_push (param_type_list, TREE_TYPE (t));
-
- type = build_function_type_vec (return_type, param_type_list);
-
- /* TYPE may have been shared since GCC hashes types. If it has a different
- CICO_LIST, make a copy. Likewise for the various flags. */
- if (!fntype_same_flags_p (type, cico_list, return_unconstrained_p,
- return_by_direct_ref_p, return_by_invisi_ref_p))
- {
- type = copy_type (type);
- TYPE_CI_CO_LIST (type) = cico_list;
- TYPE_RETURN_UNCONSTRAINED_P (type) = return_unconstrained_p;
- TYPE_RETURN_BY_DIRECT_REF_P (type) = return_by_direct_ref_p;
- TREE_ADDRESSABLE (type) = return_by_invisi_ref_p;
- }
-
- return type;
-}
-
/* Return a copy of TYPE but safe to modify in any way. */
tree
@@ -2742,12 +2702,10 @@ create_field_decl (tree name, tree type, tree record_type, tree size, tree pos,
return field_decl;
}
-/* Return a PARM_DECL node. NAME is the name of the parameter and TYPE is
- its type. READONLY is true if the parameter is readonly (either an In
- parameter or an address of a pass-by-ref parameter). */
+/* Return a PARM_DECL node with NAME and TYPE. */
tree
-create_param_decl (tree name, tree type, bool readonly)
+create_param_decl (tree name, tree type)
{
tree param_decl = build_decl (input_location, PARM_DECL, name, type);
@@ -2775,7 +2733,6 @@ create_param_decl (tree name, tree type, bool readonly)
}
DECL_ARG_TYPE (param_decl) = type;
- TREE_READONLY (param_decl) = readonly;
return param_decl;
}
@@ -3151,8 +3108,10 @@ create_label_decl (tree name, Node_Id gnat_node)
INLINE_STATUS describes the inline flags to be set on the FUNCTION_DECL.
- CONST_FLAG, PUBLIC_FLAG, EXTERN_FLAG, VOLATILE_FLAG are used to set the
- appropriate flags on the FUNCTION_DECL.
+ PUBLIC_FLAG is true if this is for a reference to a public entity or for a
+ definition to be made visible outside of the current compilation unit.
+
+ EXTERN_FLAG is true when processing an external subprogram declaration.
ARTIFICIAL_P is true if the subprogram was generated by the compiler.
@@ -3164,18 +3123,20 @@ create_label_decl (tree name, Node_Id gnat_node)
tree
create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list,
- enum inline_status_t inline_status, bool const_flag,
- bool public_flag, bool extern_flag, bool volatile_flag,
- bool artificial_p, bool debug_info_p,
+ enum inline_status_t inline_status, bool public_flag,
+ bool extern_flag, bool artificial_p, bool debug_info_p,
struct attrib *attr_list, Node_Id gnat_node)
{
tree subprog_decl = build_decl (input_location, FUNCTION_DECL, name, type);
- tree result_decl
- = build_decl (input_location, RESULT_DECL, NULL_TREE, TREE_TYPE (type));
DECL_ARGUMENTS (subprog_decl) = param_decl_list;
+ finish_subprog_decl (subprog_decl, type);
DECL_ARTIFICIAL (subprog_decl) = artificial_p;
DECL_EXTERNAL (subprog_decl) = extern_flag;
+ TREE_PUBLIC (subprog_decl) = public_flag;
+
+ if (!debug_info_p)
+ DECL_IGNORED_P (subprog_decl) = 1;
switch (inline_status)
{
@@ -3204,20 +3165,6 @@ create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list,
gcc_unreachable ();
}
- if (!debug_info_p)
- DECL_IGNORED_P (subprog_decl) = 1;
-
- TREE_READONLY (subprog_decl) = TYPE_READONLY (type) | const_flag;
- TREE_PUBLIC (subprog_decl) = public_flag;
- TREE_SIDE_EFFECTS (subprog_decl)
- = TREE_THIS_VOLATILE (subprog_decl)
- = TYPE_VOLATILE (type) | volatile_flag;
-
- DECL_ARTIFICIAL (result_decl) = 1;
- DECL_IGNORED_P (result_decl) = 1;
- DECL_BY_REFERENCE (result_decl) = TREE_ADDRESSABLE (type);
- DECL_RESULT (subprog_decl) = result_decl;
-
process_attributes (&subprog_decl, &attr_list, true, gnat_node);
/* Add this decl to the current binding level. */
@@ -3246,6 +3193,25 @@ create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list,
return subprog_decl;
}
+
+/* Given a subprogram declaration DECL and its TYPE, finish constructing the
+ subprogram declaration from TYPE. */
+
+void
+finish_subprog_decl (tree decl, tree type)
+{
+ tree result_decl
+ = build_decl (DECL_SOURCE_LOCATION (decl), RESULT_DECL, NULL_TREE,
+ TREE_TYPE (type));
+
+ DECL_ARTIFICIAL (result_decl) = 1;
+ DECL_IGNORED_P (result_decl) = 1;
+ DECL_BY_REFERENCE (result_decl) = TREE_ADDRESSABLE (type);
+ DECL_RESULT (decl) = result_decl;
+
+ TREE_READONLY (decl) = TYPE_READONLY (type);
+ TREE_SIDE_EFFECTS (decl) = TREE_THIS_VOLATILE (decl) = TYPE_VOLATILE (type);
+}
/* Set up the framework for generating code for SUBPROG_DECL, a subprogram
body. This routine needs to be invoked before processing the declarations
@@ -3992,6 +3958,7 @@ update_pointer_to (tree old_type, tree new_type)
TYPE_OBJECT_RECORD_TYPE (new_type));
TYPE_POINTER_TO (old_type) = NULL_TREE;
+ TYPE_REFERENCE_TO (old_type) = NULL_TREE;
}
}