]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Restore defensive guard in checks for volatile actuals
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 30 Mar 2022 10:00:20 +0000 (12:00 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 17 May 2022 08:25:50 +0000 (08:25 +0000)
When flagging names of volatile objects occurring in actual parameters
it is safer to guard against identifiers without entity. This is
redundant (because earlier in the resolution of actual parameters we
already guard against actuals with Any_Type), but perhaps such
identifiers will become allowed in constructs like:

   Subprogram_Call
     (Actual =>
        (declare
           X : Boolean := ...
             with Annotate (GNATprove, ...)));
                            ^^^^^^^^^

which include an identifier that does not denote any entity.

Code cleanup related to handling of volatile components; behaviour is
unaffected.

gcc/ada/

* sem_res.adb (Flag_Effectively_Volatile_Objects): Restore
redundant guard.

gcc/ada/sem_res.adb

index 12735daab6d4344d3bed7a72df346b7b9708d42c..33f445d69b9c2866e2997da5e5da071c30ea3ba9 100644 (file)
@@ -3873,7 +3873,8 @@ package body Sem_Res is
                   --  selector_name in selected_component or as a choice in
                   --  component_association.
 
-                  if Is_Object (Id)
+                  if Present (Id)
+                    and then Is_Object (Id)
                     and then Ekind (Id) not in E_Component | E_Discriminant
                     and then Is_Effectively_Volatile_For_Reading (Id)
                     and then