Routine Is_CCT_Instance (where CCT stands for Current Concurrent Type)
is now used in the SPARK backend for checking references to the current
type instance within default expressions of discriminants and components of
(single) concurrent units.

The same backend code was already used for similar references in records
and to reuse it the Is_CCT_Instance can now be called for record types.

No frontend test provided, because only the SPARK backend is affected.

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

2017-11-16  Piotr Trojanek  <troja...@adacore.com>

        * sem_util.ads, sem_util.adb (Is_CCT_Instance): Allow calls where
        Context_Id denotes a record type.

Index: sem_util.adb
===================================================================
--- sem_util.adb        (revision 254802)
+++ sem_util.adb        (working copy)
@@ -12890,8 +12890,9 @@
                                               E_Package,
                                               E_Procedure,
                                               E_Protected_Type,
-                                              E_Task_Type));
-
+                                              E_Task_Type)
+                          or else
+                        Is_Record_Type (Context_Id));
          return Scope_Within_Or_Same (Context_Id, Ref_Id);
       end if;
    end Is_CCT_Instance;
Index: sem_util.ads
===================================================================
--- sem_util.ads        (revision 254802)
+++ sem_util.ads        (working copy)
@@ -1536,9 +1536,10 @@
      (Ref_Id     : Entity_Id;
       Context_Id : Entity_Id) return Boolean;
    --  Subsidiary to the analysis of pragmas [Refined_]Depends and [Refined_]
-   --  Global. Determine whether entity Ref_Id (which must represent either
-   --  a protected type or a task type) denotes the current instance of a
-   --  concurrent type. Context_Id denotes the associated context where the
+   --  Global; also used when analyzing default expressions of protected and
+   --  record components. Determine whether entity Ref_Id (which must represent
+   --  either a protected type or a task type) denotes the current instance of
+   --  a concurrent type. Context_Id denotes the associated context where the
    --  pragma appears.
 
    function Is_Child_Or_Sibling

Reply via email to