decl.c (gnat_to_gnu_entity): Do not look up the REP part of the base type in advance.

* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Subtype>: Do not
	look up the REP part of the base type in advance.  Deal with that of
	the variant types.
	(get_rep_part): Be prepared for record types with fields.

From-SVN: r189667
This commit is contained in:
Eric Botcazou 2012-07-19 15:46:06 +00:00 committed by Eric Botcazou
parent 59f205ff69
commit 442a102d18
4 changed files with 57 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2012-07-19 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Subtype>: Do not
look up the REP part of the base type in advance. Deal with that of
the variant types.
(get_rep_part): Be prepared for record types with fields.
2012-07-03 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Call_to_gnu): Robustify test for function case

View File

@ -3288,9 +3288,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
else
gnu_unpad_base_type = gnu_base_type;
/* Look for a REP part in the base type. */
gnu_rep_part = get_rep_part (gnu_unpad_base_type);
/* Look for a variant part in the base type. */
gnu_variant_part = get_variant_part (gnu_unpad_base_type);
@ -3418,7 +3415,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
and put the field either in the new type if there is a
selected variant or in one of the new variants. */
if (gnu_context == gnu_unpad_base_type
|| (gnu_rep_part
|| ((gnu_rep_part = get_rep_part (gnu_unpad_base_type))
&& gnu_context == TREE_TYPE (gnu_rep_part)))
gnu_cont_type = gnu_type;
else
@ -3429,7 +3426,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
t = NULL_TREE;
FOR_EACH_VEC_ELT_REVERSE (variant_desc,
gnu_variant_list, ix, v)
if (v->type == gnu_context)
if (gnu_context == v->type
|| ((gnu_rep_part = get_rep_part (v->type))
&& gnu_context == TREE_TYPE (gnu_rep_part)))
{
t = v->type;
break;
@ -8898,7 +8897,8 @@ get_rep_part (tree record_type)
/* The REP part is the first field, internal, another record, and its name
starts with an 'R'. */
if (DECL_INTERNAL_P (field)
if (field
&& DECL_INTERNAL_P (field)
&& TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
&& IDENTIFIER_POINTER (DECL_NAME (field)) [0] == 'R')
return field;

View File

@ -1,3 +1,7 @@
2012-07-19 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/discr38.adb: New test.
2012-07-19 Jakub Jelinek <jakub@redhat.com>
PR middle-end/54017

View File

@ -0,0 +1,40 @@
-- { dg-do compile }
procedure Discr38 is
type Enum is (OK,
NOT_CONNECTED,
DISCONNECTED,
REQUEST_Q_EMPTY,
SERVER_UNAVAILABLE,
BUFFER_TOO_SMALL,
NO_FREE_SLOT,
RAISE_EXCEPTION,
REQUEST_CANCELLED,
REQUEST_IN_PROGRESS,
SERVER_BUSY,
BLOCK_ACKNOWLEDGE);
type R (Status : Enum := OK) is record
Status_Block : Integer;
case Status is
when RAISE_EXCEPTION =>
I : Integer;
when OK =>
Length : Natural;
Data : Integer;
when others =>
null;
end case;
end record;
for R use record
Status at 0 range 0 .. 7;
Status_Block at 4 range 0 .. 31;
Length at 8 range 0 .. 31;
end record;
Nil : constant R := (OK, 1, 0, 1);
begin
null;
end;