[Ada] Attribute Address is not an interfering context in SPARK

Message ID 20210507093823.GA140679@adacore.com
State New
Headers show
  • [Ada] Attribute Address is not an interfering context in SPARK
Related show

Commit Message

Pierre-Marie de Rodat May 7, 2021, 9:38 a.m.
Allow taking the address of a volatile object in SPARK, as it doesn't
cause problems related to interfering contexts.

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


	* sem_res.adb (Flag_Object): Ignore prefixes of attribute


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
@@ -3749,6 +3749,19 @@  package body Sem_Res is
             case Nkind (N) is
+               --  Do not consider object name appearing in the prefix of
+               --  attribute Address as a read.
+               when N_Attribute_Reference =>
+                  --  Prefix of attribute Address denotes an object, program
+                  --  unit, or label; none of them needs to be flagged here.
+                  if Attribute_Name (N) = Name_Address then
+                     return Skip;
+                  end if;
                --  Do not consider nested function calls because they have
                --  already been processed during their own resolution.