+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
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;
}
+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.
--- /dev/null
+-- { 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;