[Ada] Accept effectively volatile components in actuals
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 16 Feb 2022 11:13:57 +0000 (12:13 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 13 May 2022 08:04:26 +0000 (08:04 +0000)
In SPARK we forbid names that are effectively volatile for reading if
they occur in actual subprogram parameters. We wrongly rejected
references to components, which are not names in Ada.

gcc/ada/

* sem_res.adb (Flag_Effectively_Volatile_Objects): Ignore
component and discriminant identifiers.

gcc/ada/sem_res.adb

index 4ae0835..4306e49 100644 (file)
@@ -3868,7 +3868,13 @@ package body Sem_Res is
                when N_Identifier | N_Expanded_Name =>
                   Id := Entity (N);
 
+                  --  Identifiers of components and discriminants are not names
+                  --  in the sense of Ada RM 4.1. They can only occur as a
+                  --  selector_name in selected_component or as a choice in
+                  --  component_association.
+
                   if Is_Object (Id)
+                    and then Ekind (Id) not in E_Component | E_Discriminant
                     and then Is_Effectively_Volatile_For_Reading (Id)
                     and then
                       not Is_OK_Volatile_Context (Context       => Parent (N),