decl.c (build_subst_list): Convert the expression of the constraint to the type of the discriminant.
* gcc-interfaces/decl.c (build_subst_list): Convert the expression of the constraint to the type of the discriminant. From-SVN: r153054
This commit is contained in:
parent
9a1c0fd9f2
commit
3c28a5f48c
@ -1,3 +1,8 @@
|
||||
2009-10-21 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gcc-interfaces/decl.c (build_subst_list): Convert the expression of
|
||||
the constraint to the type of the discriminant.
|
||||
|
||||
2009-10-21 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gcc-interfaces/decl.c (gnat_to_gnu_entity): Do not create a new
|
||||
|
@ -7374,12 +7374,16 @@ build_subst_list (Entity_Id gnat_subtype, Entity_Id gnat_type, bool definition)
|
||||
gnat_value = Next_Elmt (gnat_value))
|
||||
/* Ignore access discriminants. */
|
||||
if (!Is_Access_Type (Etype (Node (gnat_value))))
|
||||
gnu_list = tree_cons (gnat_to_gnu_field_decl (gnat_discrim),
|
||||
elaborate_expression
|
||||
(Node (gnat_value), gnat_subtype,
|
||||
get_entity_name (gnat_discrim), definition,
|
||||
true, false),
|
||||
gnu_list);
|
||||
{
|
||||
tree gnu_field = gnat_to_gnu_field_decl (gnat_discrim);
|
||||
gnu_list = tree_cons (gnu_field,
|
||||
convert (TREE_TYPE (gnu_field),
|
||||
elaborate_expression
|
||||
(Node (gnat_value), gnat_subtype,
|
||||
get_entity_name (gnat_discrim),
|
||||
definition, true, false)),
|
||||
gnu_list);
|
||||
}
|
||||
|
||||
return gnu_list;
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
2009-10-21 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gnat.dg/discr22.adb: New test.
|
||||
|
||||
2009-10-21 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gnat.dg/loop_optimization7.ad[sb]: New test.
|
||||
|
23
gcc/testsuite/gnat.dg/discr22.adb
Normal file
23
gcc/testsuite/gnat.dg/discr22.adb
Normal file
@ -0,0 +1,23 @@
|
||||
-- { dg-do compile }
|
||||
-- { dg-options "-gnatws" }
|
||||
|
||||
procedure Discr22 is
|
||||
|
||||
subtype Precision is Integer range 1 .. 5;
|
||||
|
||||
type Rec(D1 : Precision; D2 : Integer) is record
|
||||
case D1 is
|
||||
when 1 => I : Integer;
|
||||
when others => null;
|
||||
end case;
|
||||
end record;
|
||||
for Rec use record
|
||||
D1 at 0 range 0 .. 7;
|
||||
end record;
|
||||
|
||||
P : Precision;
|
||||
X : Rec(P, 0);
|
||||
|
||||
begin
|
||||
null;
|
||||
end;
|
Loading…
Reference in New Issue
Block a user