aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-04-27 18:08:39 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-04-27 18:08:39 +0000
commit1e55d29a0c643ebef76b6056077e9f78686669d6 (patch)
treec55480876dc3fe6269c2e5c4075b0b3b34bf2b5d /gcc/ada/gcc-interface/utils.c
parente306693a820abb242c4ccfce28bbd0f9cec7bda9 (diff)
downloadgcc-1e55d29a0c643ebef76b6056077e9f78686669d6.zip
gcc-1e55d29a0c643ebef76b6056077e9f78686669d6.tar.gz
gcc-1e55d29a0c643ebef76b6056077e9f78686669d6.tar.bz2
sem_aux.adb (Is_By_Reference_Type): Also return true for a tagged incomplete type without full view.
* sem_aux.adb (Is_By_Reference_Type): Also return true for a tagged incomplete type without full view. * sem_ch6.adb (Exchange_Limited_Views): Change into a function and return the list of changes. (Restore_Limited_Views): New procedure to undo the transformation made by Exchange_Limited_Views. (Analyze_Subprogram_Body_Helper): Adjust call to Exchange_Limited_Views and call Restore_Limited_Views at the end, if need be. (Possible_Freeze): Do not delay freezing because of incomplete types. (Process_Formals): Remove kludges for class-wide types. * types.h (By_Copy_Return): Delete. * gcc-interface/ada-tree.h (TYPE_MAX_ALIGN): Move around. (TYPE_DUMMY_IN_PROFILE_P): New macro. * gcc-interface/gigi.h (update_profiles_with): Declare. (finish_subprog_decl): Likewise. (get_minimal_subprog_decl): Delete. (create_subprog_type): Likewise. (create_param_decl): Adjust prototype. (create_subprog_decl): Likewise. * gcc-interface/decl.c (defer_limited_with): Rename into... (defer_limited_with_list): ...this. (gnat_to_gnu_entity): Adjust to above renaming. (finalize_from_limited_with): Likewise. (tree_entity_vec_map): New structure. (gt_pch_nx): New helpers. (dummy_to_subprog_map): New hash table. (gnat_to_gnu_param): Set the SLOC here. Remove MECH parameter and add FIRST parameter. Deal with the mechanism here instead of... Do not make read-only variant of types. Simplify expressions. In the by-ref case, test the mechanism before must_pass_by_ref and also TYPE_IS_BY_REFERENCE_P before building the reference type. (gnat_to_gnu_subprog_type): New static function extracted from... Do not special-case the type_annotate_only mode. Call gnat_to_gnu_profile_type instead of gnat_to_gnu_type on return type. Deal with dummy return types. Likewise for parameter types. Deal with by-reference types explicitly and add a kludge for null procedures with untagged incomplete types. Remove assertion on the types and be prepared for multiple elaboration of the declarations. Skip the whole CICO processing if the profile is incomplete. Handle the completion of a previously incomplete profile. (gnat_to_gnu_entity) <E_Variable>: Rename local variable. Adjust couple of calls to create_param_decl. <E_Access_Subprogram_Type, E_Anonymous_Access_Subprogram_Type>: Remove specific deferring code. <E_Access_Type>: Also deal with E_Subprogram_Type designated type. Simplify handling of dummy types and remove obsolete comment. Constify a couple of variables. Do not set TYPE_UNIVERSAL_ALIASING_P on dummy types. <E_Access_Subtype>: Tweak comment and simplify condition. <E_Subprogram_Type>: ...here. Call it and clean up handling. Remove obsolete comment and adjust call to gnat_to_gnu_param. Adjust call to create_subprog_decl. <E_Incomplete_Type>: Add a couple of 'const' qualifiers and get rid of inner break statements. Tidy up condition guarding direct use of the full view. (get_minimal_subprog_decl): Delete. (finalize_from_limited_with): Call update_profiles_with on dummy types with TYPE_DUMMY_IN_PROFILE_P set. (is_from_limited_with_of_main): Delete. (associate_subprog_with_dummy_type): New function. (update_profile): Likewise. (update_profiles_with): Likewise. (gnat_to_gnu_profile_type): Likewise. (init_gnat_decl): Initialize dummy_to_subprog_map. (destroy_gnat_decl): Destroy dummy_to_subprog_map. * gcc-interface/misc.c (gnat_get_alias_set): Add guard for accessing TYPE_UNIVERSAL_ALIASING_P. (gnat_get_array_descr_info): Minor tweak. * gcc-interface/trans.c (gigi): Adjust calls to create_subprog_decl. (build_raise_check): Likewise. (Compilation_Unit_to_gnu): Likewise. (Identifier_to_gnu): Accept mismatches coming from a limited context. (Attribute_to_gnu): Remove kludge for dispatch table entities. (process_freeze_entity): Do not retrieve old definition if there is an address clause on the entity. Call update_profiles_with on dummy types with TYPE_DUMMY_IN_PROFILE_P set. * gcc-interface/utils.c (build_dummy_unc_pointer_types): Also set TYPE_REFERENCE_TO to the fat pointer type. (create_subprog_type): Delete. (create_param_decl): Remove READONLY parameter. (finish_subprog_decl): New function extracted from... (create_subprog_decl): ...here. Call it. Remove CONST_FLAG and VOLATILE_FLAG parameters and adjust. (update_pointer_to): Also clear TYPE_REFERENCE_TO in the unconstrained case. From-SVN: r235521
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;
}
}