[Ada] Restore defensive guard in checks for volatile actuals

Message ID 20220517082759.GA1092896@adacore.com
State Committed
Commit 33400df641d834ca3fd3f2c964ed92759f128ffa
Headers
Series [Ada] Restore defensive guard in checks for volatile actuals |

Commit Message

Pierre-Marie de Rodat May 17, 2022, 8:27 a.m. UTC
  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.

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

gcc/ada/

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

Patch

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -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