diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-02-06 12:13:07 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-02-06 12:13:07 +0100 |
commit | 42ae387068be90759ead414855ecd14e933b0a4e (patch) | |
tree | 2d2c0a48d50ef471daf900e9946d67c3a8d2ec61 /gcc/ada/gcc-interface/decl.c | |
parent | f403355afb84e58c73c83329b18bac3bc24f336c (diff) | |
download | gcc-42ae387068be90759ead414855ecd14e933b0a4e.zip gcc-42ae387068be90759ead414855ecd14e933b0a4e.tar.gz gcc-42ae387068be90759ead414855ecd14e933b0a4e.tar.bz2 |
[multiple changes]
2013-02-06 Vincent Celier <celier@adacore.com>
* prj-proc.adb (Process_Aggregated_Projects): Use a new project
node tree for each project tree rooted at an aggregated project.
2013-02-06 Hristian Kirtchev <kirtchev@adacore.com>
* sem_util.adb (Is_Interface_Conversion): New routine.
(Object_Access_Level): Detect an interface conversion
that has been rewritten into a different construct. Use the
original form of the conversion to find the access level of
the operand.
2013-02-06 Eric Botcazou <ebotcazou@adacore.com>
* einfo.ads (Has_Pragma_No_Inline): New flag using Flag201.
(Has_Pragma_No_Inline): Declare and mark as inline.
(Set_Has_Pragma_No_Inline): Likewise.
* einfo.adb (Has_Pragma_No_Inline): New function.
(Set_Has_Pragma_No_Inline): New procedure.
(Write_Entity_Flags): Handle Has_Pragma_No_Inline.
* snames.ads-tmpl (Name_No_Inline): New pragma-related name.
(Pragma_Id): Add Pragma_No_Inline value.
* par-prag.adb (Prag): Handle Pragma_Inline.
* sem_prag.adb (Inline_Status): New enumeration type.
(Process_Inline): Change Active parameter
to Inline_Status and add support for suppressed inlining.
(Analyze_Pragma) <Pragma_Inline>: Adjust to above change.
<Pragma_Inline_Always>: Likewise.
<Pragma_No_Inline>: Implement new pragma No_Inline.
(Sig_Flags): Add Pragma_No_Inline.
* gnat_rm.texi (Implementation Defined Pragmas): Add No_Inline.
* gnat_ugn.texi (Switches for gcc): Mention Pragma No_Inline.
2013-02-06 Pascal Obry <obry@adacore.com>
* s-osprim-mingw.adb (Clock): Make sure we copy all data locally
to avoid interleaved modifications that could happen from another
task calling Get_Base_Data.
(Get_Base_Data): Make it a critical section. Avoid updating if another
task has already done it.
From-SVN: r195801
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 88 |
1 files changed, 69 insertions, 19 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 56b64a3..2af3ca8 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -2908,10 +2908,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) { Node_Id full_definition = Declaration_Node (gnat_entity); Node_Id record_definition = Type_Definition (full_definition); + Node_Id gnat_constr; Entity_Id gnat_field; - tree gnu_field, gnu_field_list = NULL_TREE, gnu_get_parent; + tree gnu_field, gnu_field_list = NULL_TREE; + tree gnu_get_parent; /* Set PACKED in keeping with gnat_to_gnu_field. */ - int packed + const int packed = Is_Packed (gnat_entity) ? 1 : Component_Alignment (gnat_entity) == Calign_Storage_Unit @@ -2921,13 +2923,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) && Known_RM_Size (gnat_entity))) ? -2 : 0; - bool has_discr = Has_Discriminants (gnat_entity); - bool has_rep = Has_Specified_Layout (gnat_entity); - bool all_rep = has_rep; - bool is_extension + const bool has_discr = Has_Discriminants (gnat_entity); + const bool has_rep = Has_Specified_Layout (gnat_entity); + const bool is_extension = (Is_Tagged_Type (gnat_entity) && Nkind (record_definition) == N_Derived_Type_Definition); - bool is_unchecked_union = Is_Unchecked_Union (gnat_entity); + const bool is_unchecked_union = Is_Unchecked_Union (gnat_entity); + bool all_rep = has_rep; /* See if all fields have a rep clause. Stop when we find one that doesn't. */ @@ -3166,6 +3168,51 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) } } + /* If we have a derived untagged type that renames discriminants in + the root type, the (stored) discriminants are a just copy of the + discriminants of the root type. This means that any constraints + added by the renaming in the derivation are disregarded as far + as the layout of the derived type is concerned. To rescue them, + we change the type of the (stored) discriminants to a subtype + with the bounds of the type of the visible discriminants. */ + if (has_discr + && !is_extension + && Stored_Constraint (gnat_entity) != No_Elist) + for (gnat_constr = First_Elmt (Stored_Constraint (gnat_entity)); + gnat_constr != No_Elmt; + gnat_constr = Next_Elmt (gnat_constr)) + if (Nkind (Node (gnat_constr)) == N_Identifier + /* Ignore access discriminants. */ + && !Is_Access_Type (Etype (Node (gnat_constr))) + && Ekind (Entity (Node (gnat_constr))) == E_Discriminant) + { + Entity_Id gnat_discr = Entity (Node (gnat_constr)); + tree gnu_discr_type = gnat_to_gnu_type (Etype (gnat_discr)); + tree gnu_ref + = gnat_to_gnu_entity (Original_Record_Component (gnat_discr), + NULL_TREE, 0); + + /* GNU_REF must be an expression using a PLACEHOLDER_EXPR built + just above for one of the stored discriminants. */ + gcc_assert (TREE_TYPE (TREE_OPERAND (gnu_ref, 0)) == gnu_type); + + if (gnu_discr_type != TREE_TYPE (gnu_ref)) + { + const unsigned prec = TYPE_PRECISION (TREE_TYPE (gnu_ref)); + tree gnu_subtype + = TYPE_UNSIGNED (TREE_TYPE (gnu_ref)) + ? make_unsigned_type (prec) : make_signed_type (prec); + TREE_TYPE (gnu_subtype) = TREE_TYPE (gnu_ref); + TYPE_EXTRA_SUBTYPE_P (gnu_subtype) = 1; + SET_TYPE_RM_MIN_VALUE (gnu_subtype, + TYPE_MIN_VALUE (gnu_discr_type)); + SET_TYPE_RM_MAX_VALUE (gnu_subtype, + TYPE_MAX_VALUE (gnu_discr_type)); + TREE_TYPE (gnu_ref) + = TREE_TYPE (TREE_OPERAND (gnu_ref, 1)) = gnu_subtype; + } + } + /* Add the fields into the record type and finish it up. */ components_to_record (gnu_type, Component_List (record_definition), gnu_field_list, packed, definition, false, @@ -4078,7 +4125,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) tree gnu_stub_type = NULL_TREE, gnu_stub_name = NULL_TREE; tree gnu_ext_name = create_concat_name (gnat_entity, NULL); Entity_Id gnat_param; - bool inline_flag = Is_Inlined (gnat_entity); + enum inline_status_t inline_status + = Has_Pragma_No_Inline (gnat_entity) + ? is_suppressed + : (Is_Inlined (gnat_entity) ? is_enabled : is_disabled); bool public_flag = Is_Public (gnat_entity) || imported_p; bool extern_flag = (Is_Public (gnat_entity) && !definition) || imported_p; @@ -4634,15 +4684,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) gnu_decl = create_subprog_decl (gnu_entity_name, gnu_ext_name, gnu_type, - gnu_param_list, inline_flag, public_flag, - extern_flag, artificial_flag, attr_list, - gnat_entity); + gnu_param_list, inline_status, + public_flag, extern_flag, artificial_flag, + attr_list, gnat_entity); if (has_stub) { tree gnu_stub_decl = create_subprog_decl (gnu_entity_name, gnu_stub_name, gnu_stub_type, gnu_stub_param_list, - inline_flag, true, extern_flag, + inline_status, true, extern_flag, false, attr_list, gnat_entity); SET_DECL_FUNCTION_STUB (gnu_decl, gnu_stub_decl); } @@ -5375,7 +5425,7 @@ get_minimal_subprog_decl (Entity_Id gnat_entity) return create_subprog_decl (gnu_entity_name, gnu_ext_name, void_ftype, NULL_TREE, - false, true, true, true, attr_list, gnat_entity); + is_disabled, true, true, true, attr_list, gnat_entity); } /* Return whether the E_Subprogram_Type/E_Function/E_Procedure GNAT_ENTITY is @@ -5964,7 +6014,7 @@ elaborate_entity (Entity_Id gnat_entity) Present (gnat_field); gnat_field = Next_Discriminant (gnat_field), gnat_discriminant_expr = Next_Elmt (gnat_discriminant_expr)) - /* ??? For now, ignore access discriminants. */ + /* Ignore access discriminants. */ if (!Is_Access_Type (Etype (Node (gnat_discriminant_expr)))) elaborate_expression (Node (gnat_discriminant_expr), gnat_entity, get_entity_name (gnat_field), @@ -7610,20 +7660,20 @@ build_subst_list (Entity_Id gnat_subtype, Entity_Id gnat_type, bool definition) { vec<subst_pair> gnu_list = vNULL; Entity_Id gnat_discrim; - Node_Id gnat_value; + Node_Id gnat_constr; for (gnat_discrim = First_Stored_Discriminant (gnat_type), - gnat_value = First_Elmt (Stored_Constraint (gnat_subtype)); + gnat_constr = First_Elmt (Stored_Constraint (gnat_subtype)); Present (gnat_discrim); gnat_discrim = Next_Stored_Discriminant (gnat_discrim), - gnat_value = Next_Elmt (gnat_value)) + gnat_constr = Next_Elmt (gnat_constr)) /* Ignore access discriminants. */ - if (!Is_Access_Type (Etype (Node (gnat_value)))) + if (!Is_Access_Type (Etype (Node (gnat_constr)))) { tree gnu_field = gnat_to_gnu_field_decl (gnat_discrim); tree replacement = convert (TREE_TYPE (gnu_field), elaborate_expression - (Node (gnat_value), gnat_subtype, + (Node (gnat_constr), gnat_subtype, get_entity_name (gnat_discrim), definition, true, false)); subst_pair s = {gnu_field, replacement}; |