+2019-07-05 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_util.adb (Encloing_Subprogram): If Enclosing_Dynamic_Scope
+ is a loop, continue climbing the scope stack to find the
+ enclosing subprogram.
+ (Gather_Components): Handle properly a choice in a record
+ aggregate that is given by a subtype with a static predicate.
+
2019-07-05 Javier Miranda <miranda@adacore.com>
* debug.adb (-gnatd.K): Leave available this switch.
elsif Ekind (Dyn_Scop) = E_Subprogram_Body then
return Corresponding_Spec (Parent (Parent (Dyn_Scop)));
- elsif Ekind_In (Dyn_Scop, E_Block, E_Return_Statement) then
+ elsif Ekind_In (Dyn_Scop, E_Block, E_Return_Statement, E_Loop) then
return Enclosing_Subprogram (Dyn_Scop);
elsif Ekind (Dyn_Scop) = E_Entry then
begin
Find_Discrete_Value : while Present (Variant) loop
+
+ -- If a choice is a subtype with a static predicate, it must
+ -- be rewritten as an explicit list of non-predicated choices.
+
+ Expand_Static_Predicates_In_Choices (Variant);
+
Discrete_Choice := First (Discrete_Choices (Variant));
while Present (Discrete_Choice) loop
exit Find_Discrete_Value when
+2019-07-05 Ed Schonberg <schonberg@adacore.com>
+
+ * gnat.dg/aggr25.adb, gnat.dg/aggr25.ads: New testcase.
+
2019-07-05 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/predicate7.adb, gnat.dg/predicate7.ads,
--- /dev/null
+-- { dg-do compile }
+
+package body Aggr25 is
+
+ procedure Foo is null;
+
+end Aggr25;
--- /dev/null
+package Aggr25 is
+
+ type T_A is (A, B , C ,D);
+
+ subtype Has_B_D is T_A with Static_Predicate => Has_B_D in B | D;
+
+ type Obj_T (Kind : T_A) is
+ record
+ case Kind is
+ --OK-- when A | C => null; --OK--
+ when Has_B_D => Value : Boolean;
+ --BAD-- when A | C => null;
+ when others => null;
+ end case;
+ end record;
+
+ type T is access Obj_T;
+
+ Unavailable : constant T := new Obj_T'(Kind => A);
+
+ procedure Foo;
+
+end Aggr25;