diff options
author | Marc Poulhiès <poulhies@adacore.com> | 2022-12-20 15:54:00 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-30 09:12:17 +0200 |
commit | b3c206bf46a36bac12cbd863be092625593ad0bb (patch) | |
tree | 4c9a33d0f5bec8441bb1f2643340c4e8d7f9e12b /gcc/ada/gcc-interface/trans.cc | |
parent | 4f061cf29a348178e084ef179a23c6b950a0e283 (diff) | |
download | gcc-b3c206bf46a36bac12cbd863be092625593ad0bb.zip gcc-b3c206bf46a36bac12cbd863be092625593ad0bb.tar.gz gcc-b3c206bf46a36bac12cbd863be092625593ad0bb.tar.bz2 |
ada: Fix storage model handling for dereference as lvalue and renamings
Don't require storage access for explicit dereferences used as
lvalue (e.g. Some_Access.all'Address) or for renamings.
gcc/ada/
* gcc-interface/trans.cc (get_storage_model_access): Don't require
storage model access for dereference used as lvalue or renamings.
Diffstat (limited to 'gcc/ada/gcc-interface/trans.cc')
-rw-r--r-- | gcc/ada/gcc-interface/trans.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 13f438c..f4a5db0 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -4398,14 +4398,32 @@ static void get_storage_model_access (Node_Id gnat_node, Entity_Id *gnat_smo) { const Node_Id gnat_parent = Parent (gnat_node); + *gnat_smo = Empty; - /* If we are the prefix of the parent, then the access is above us. */ - if (node_is_component (gnat_parent) && Prefix (gnat_parent) == gnat_node) + switch (Nkind (gnat_parent)) { - *gnat_smo = Empty; + case N_Attribute_Reference: + /* If the parent is an attribute reference that requires an lvalue and + gnat_node is the Prefix (i.e. not a parameter), we do not need to + actually access any storage. */ + if (lvalue_required_for_attribute_p (gnat_parent) + && Prefix (gnat_parent) == gnat_node) + return; + break; + + case N_Object_Renaming_Declaration: + /* Nothing to do for the identifier in an object renaming declaration, + the renaming itself does not need storage model access. */ return; + + default: + break; } + /* If we are the prefix of the parent, then the access is above us. */ + if (node_is_component (gnat_parent) && Prefix (gnat_parent) == gnat_node) + return; + /* Now strip any type conversion from GNAT_NODE. */ if (Nkind (gnat_node) == N_Type_Conversion || Nkind (gnat_node) == N_Unchecked_Type_Conversion) |