This patch allows First_Component and First_Component_Or_Discriminant to apply
to protected and task types. No change in behavior, no test needed. The patch
is aimed at clients of the compiler front-end.

Tested on x86_64-pc-linux-gnu, committed on trunk

2015-10-26  Hristian Kirtchev  <kirtc...@adacore.com>

        * einfo.adb (First_Component): Update the assertion to allow
        for concurrent types.
        (First_Component_Or_Discriminant): Update the assertion to allow for
        concurrent types.
        * einfo.ads: Update the documentation of attributes First_Component
        and First_Component_Or_Discriminant along with uses in entities.

Index: einfo.adb
===================================================================
--- einfo.adb   (revision 229333)
+++ einfo.adb   (working copy)
@@ -6926,7 +6926,9 @@
 
    begin
       pragma Assert
-        (Is_Record_Type (Id) or else Is_Incomplete_Or_Private_Type (Id));
+        (Is_Concurrent_Type (Id)
+          or else Is_Incomplete_Or_Private_Type (Id)
+          or else Is_Record_Type (Id));
 
       Comp_Id := First_Entity (Id);
       while Present (Comp_Id) loop
@@ -6946,8 +6948,9 @@
 
    begin
       pragma Assert
-        (Is_Record_Type (Id)
+        (Is_Concurrent_Type (Id)
           or else Is_Incomplete_Or_Private_Type (Id)
+          or else Is_Record_Type (Id)
           or else Has_Discriminants (Id));
 
       Comp_Id := First_Entity (Id);
Index: einfo.ads
===================================================================
--- einfo.ads   (revision 229343)
+++ einfo.ads   (working copy)
@@ -1286,14 +1286,15 @@
 --       objects.
 
 --    First_Component (synthesized)
---       Applies to record types. Returns the first component by following the
---       chain of declared entities for the record until a component is found
---       (one with an Ekind of E_Component). The discriminants are skipped. If
---       the record is null, then Empty is returned.
+--       Applies to incomplete, private, protected, record and task types.
+--       Returns the first component by following the chain of declared
+--       entities for the type a component is found (one with an Ekind of
+--       E_Component). The discriminants are skipped. If the record is null,
+--       then Empty is returned.
 
 --    First_Component_Or_Discriminant (synthesized)
---      Similar to First_Component, but discriminants are not skipped, so will
---      find the first discriminant if discriminants are present.
+--       Similar to First_Component, but discriminants are not skipped, so will
+--       find the first discriminant if discriminants are present.
 
 --    First_Entity (Node17)
 --       Defined in all entities which act as scopes to which a list of
@@ -6263,6 +6264,8 @@
    --    SPARK_Pragma_Inherited              (Flag265)
    --    Uses_Lock_Free                      (Flag188)
    --    Uses_Sec_Stack                      (Flag95)   ???
+   --    First_Component                     (synth)
+   --    First_Component_Or_Discriminant     (synth)
    --    Has_Entries                         (synth)
    --    Has_Interrupt_Handler               (synth)
    --    Number_Entries                      (synth)
@@ -6410,6 +6413,8 @@
    --    SPARK_Aux_Pragma_Inherited          (Flag266)
    --    SPARK_Pragma_Inherited              (Flag265)
    --    Uses_Sec_Stack                      (Flag95)   ???
+   --    First_Component                     (synth)
+   --    First_Component_Or_Discriminant     (synth)
    --    Has_Entries                         (synth)
    --    Number_Entries                      (synth)
    --    (plus type attributes)

Reply via email to