diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-20 09:01:34 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-20 09:01:34 +0000 |
commit | 96536a9d252a60aeaa039643a1d3c616e52ad8bc (patch) | |
tree | 31f580aa64b5ca42d70c133e1b634e5d8fb6daeb /gcc/ada/gcc-interface/decl.c | |
parent | c716ac28cdbd4737f4319663ab60e22bf3affde2 (diff) | |
download | gcc-96536a9d252a60aeaa039643a1d3c616e52ad8bc.tar.gz |
* exp_ch2.adb (Expand_Current_Value): Make an appropriate character
literal if the entity is of a character type.
* gcc-interface/lang.opt (fsigned-char): New option.
* gcc-interface/misc.c (gnat_handle_option): Accept it.
(gnat_init): Adjust comment.
* gcc-interface/gigi.h (finish_character_type): New prototype.
(maybe_character_type): New inline function.
(maybe_character_value): Likewise.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Enumeration_Type>: For
a character of CHAR_TYPE_SIZE, make a signed type if flag_signed_char.
Set TYPE_ARTIFICIAL early and call finish_character_type on the type.
<E_Enumeration_Subtype>: For a subtype of character with RM_Size and
Esize equal to CHAR_TYPE_SIZE, make a signed type if flag_signed_char.
Copy TYPE_STRING_FLAG from type to subtype.
<E_Array_Type>: Deal with character index types.
<E_Array_Subtype>: Likewise.
* gcc-interface/trans.c (gigi): Replace unsigned_char_type_node with
char_type_node throughout.
(build_raise_check): Likewise.
(get_type_length): Deal with character types.
(Attribute_to_gnu) <Attr_Pos>: Likewise. Remove obsolete range check
code. Minor tweak.
<Attr_Pred>: Likewise.
(Loop_Statement_to_gnu): Likewise.
(Raise_Error_to_gnu): Likewise.
<N_Indexed_Component>: Deal with character index types. Remove
obsolete code.
<N_Slice>: Likewise.
<N_Type_Conversion>: Deal with character types. Minor tweak.
<N_Unchecked_Type_Conversion>: Likewise.
<N_In>: Likewise.
<N_Op_Eq>: Likewise.
(emit_index_check): Delete.
* gcc-interface/utils.c (finish_character_type): New function.
(gnat_signed_or_unsigned_type_for): Deal with built-in character types.
* gcc-interface/utils2.c (expand_sloc): Replace unsigned_char_type_node
with char_type_node.
(build_call_raise): Likewise.
(build_call_raise_column): Likewise.
(build_call_raise_range): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232604 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 556f079690d..74bc95bf864 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1560,16 +1560,24 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) case E_Enumeration_Type: /* A special case: for the types Character and Wide_Character in Standard, we do not list all the literals. So if the literals - are not specified, make this an unsigned integer type. */ + are not specified, make this an integer type. */ if (No (First_Literal (gnat_entity))) { - gnu_type = make_unsigned_type (esize); + if (esize == CHAR_TYPE_SIZE && flag_signed_char) + gnu_type = make_signed_type (CHAR_TYPE_SIZE); + else + gnu_type = make_unsigned_type (esize); TYPE_NAME (gnu_type) = gnu_entity_name; /* Set TYPE_STRING_FLAG for Character and Wide_Character types. This is needed by the DWARF-2 back-end to distinguish between unsigned integer types and character types. */ TYPE_STRING_FLAG (gnu_type) = 1; + + /* This flag is needed by the call just below. */ + TYPE_ARTIFICIAL (gnu_type) = artificial_p; + + finish_character_type (gnu_type); } else { @@ -1765,12 +1773,19 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) && Is_Bit_Packed_Array (Original_Array_Type (gnat_entity))) esize = UI_To_Int (RM_Size (gnat_entity)); - /* This should be an unsigned type if the base type is unsigned or + /* First subtypes of Character are treated as Character; otherwise + this should be an unsigned type if the base type is unsigned or if the lower bound is constant and non-negative or if the type is biased. */ - if (Is_Unsigned_Type (Etype (gnat_entity)) - || Is_Unsigned_Type (gnat_entity) - || Has_Biased_Representation (gnat_entity)) + if (kind == E_Enumeration_Subtype + && No (First_Literal (Etype (gnat_entity))) + && Esize (gnat_entity) == RM_Size (gnat_entity) + && esize == CHAR_TYPE_SIZE + && flag_signed_char) + gnu_type = make_signed_type (CHAR_TYPE_SIZE); + else if (Is_Unsigned_Type (Etype (gnat_entity)) + || Is_Unsigned_Type (gnat_entity) + || Has_Biased_Representation (gnat_entity)) gnu_type = make_unsigned_type (esize); else gnu_type = make_signed_type (esize); @@ -1789,6 +1804,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) TYPE_BIASED_REPRESENTATION_P (gnu_type) = Has_Biased_Representation (gnat_entity); + /* Set TYPE_STRING_FLAG for Character and Wide_Character subtypes. */ + TYPE_STRING_FLAG (gnu_type) = TYPE_STRING_FLAG (TREE_TYPE (gnu_type)); + /* Inherit our alias set from what we're a subtype of. Subtypes are not different types and a pointer can designate any instance within a subtype hierarchy. */ @@ -2114,7 +2132,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) { char field_name[16]; tree gnu_index_type = get_unpadded_type (Etype (gnat_index)); - tree gnu_index_base_type = get_base_type (gnu_index_type); + tree gnu_index_base_type + = maybe_character_type (get_base_type (gnu_index_type)); tree gnu_lb_field, gnu_hb_field, gnu_orig_min, gnu_orig_max; tree gnu_min, gnu_max, gnu_high; @@ -2363,7 +2382,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) gnat_base_index = Next_Index (gnat_base_index)) { tree gnu_index_type = get_unpadded_type (Etype (gnat_index)); - tree gnu_index_base_type = get_base_type (gnu_index_type); + tree gnu_index_base_type + = maybe_character_type (get_base_type (gnu_index_type)); tree gnu_orig_min = convert (gnu_index_base_type, TYPE_MIN_VALUE (gnu_index_type)); @@ -2375,7 +2395,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) tree gnu_base_index_type = get_unpadded_type (Etype (gnat_base_index)); tree gnu_base_index_base_type - = get_base_type (gnu_base_index_type); + = maybe_character_type (get_base_type (gnu_base_index_type)); tree gnu_base_orig_min = convert (gnu_base_index_base_type, TYPE_MIN_VALUE (gnu_base_index_type)); |