public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] [Ada] Implement AI12-0032 fixes for 'Old attribute accessibility
@ 2020-08-22 22:48 Giuliano Belinassi
0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 22:48 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2a47240d1fbee5ea0b2f0e5faab782c998516c05
commit 2a47240d1fbee5ea0b2f0e5faab782c998516c05
Author: Steve Baird <baird@adacore.com>
Date: Thu Apr 23 14:39:55 2020 -0700
[Ada] Implement AI12-0032 fixes for 'Old attribute accessibility
2020-06-18 Steve Baird <baird@adacore.com>
gcc/ada/
* sem_util.adb (Object_Access_Level): Treat a 'Old attribute
reference like an aggregate in determining its static
accessibility level; after the evaluation of the relevant
post-condition, the implicitly declared constant associated with
an Old attribute reference ceases to exist. Similarly for
Loop_Entry attribute.
* exp_ch6.adb (Expand_Call_Helper): For an attribute reference
that is expanded into a reference to an implicitly declared
constant (e.g., a 'Old or 'Loop_Entry attribute), compute the
dynamic accessibility level of that constant by looking at the
declaration of the constant (as opposed to looking at the
attribute reference).
Diff:
---
gcc/ada/exp_ch6.adb | 15 +++++++++++++++
gcc/ada/sem_util.adb | 12 ++++++++++++
2 files changed, 27 insertions(+)
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 9a32f7ed702..00a0aef0631 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -3617,6 +3617,21 @@ package body Exp_Ch6 is
then
Prev_Orig := Prev;
+ -- If the actual is an attribute reference that was expanded
+ -- into a reference to an entity, then get accessibility level
+ -- from that entity. AARM 6.1.1(27.d) says "... the implicit
+ -- constant declaration defines the accessibility level of X'Old".
+
+ elsif Nkind (Prev_Orig) = N_Attribute_Reference
+ and then Nam_In (Attribute_Name (Prev_Orig),
+ Name_Old,
+ Name_Loop_Entry)
+ and then Is_Entity_Name (Prev)
+ and then Present (Entity (Prev))
+ and then Is_Object (Entity (Prev))
+ then
+ Prev_Orig := Prev;
+
elsif Nkind (Prev_Orig) = N_Type_Conversion then
Prev_Orig := Expression (Prev_Orig);
end if;
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 756162e4a2f..40f34fd7b8a 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -24237,6 +24237,18 @@ package body Sem_Util is
elsif Nkind (Orig_Obj) = N_Aggregate then
return Object_Access_Level (Current_Scope);
+ -- Treat an Old/Loop_Entry attribute reference like an aggregate.
+ -- AARM 6.1.1(27.d) says "... the implicit constant declaration
+ -- defines the accessibility level of X'Old", so that is what
+ -- we are trying to implement here.
+
+ elsif Nkind (Orig_Obj) = N_Attribute_Reference
+ and then Nam_In (Attribute_Name (Orig_Obj),
+ Name_Old,
+ Name_Loop_Entry)
+ then
+ return Object_Access_Level (Current_Scope);
+
-- Otherwise return the scope level of Standard. (If there are cases
-- that fall through to this point they will be treated as having
-- global accessibility for now. ???)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-22 22:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 22:48 [gcc/devel/autopar_devel] [Ada] Implement AI12-0032 fixes for 'Old attribute accessibility Giuliano Belinassi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).