Target name (i.e. "@"), which was introduced to Ada 202X in AI12-0125,
denotes a constant object (RM 3.3(21.2/5)), even though target_name
itself is not an object (RM 3.3(2)).
This patch allows @ to be appear as a prefix for Address attribute
(which requires an object). Also, it enables constructs like @'Last,
where @ represents a constrained array object with a static bound, to be
constant-folded in GNATprove mode (where @ is not expanded), just like
it is constant-folded in GNAT mode (but only after @ has been expanded).
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_util.adb (Is_Object_Reference): Return True on
N_Target_Name.
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -17217,6 +17217,11 @@ package body Sem_Util is
return Is_Rewrite_Substitution (N)
and then Is_Object_Reference (Original_Node (N));
+ -- AI12-0125: Target name represents a constant object
+
+ when N_Target_Name =>
+ return True;
+
when others =>
return False;
end case;