aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch5.adb
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2021-01-12 10:46:26 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2021-05-05 04:19:03 -0400
commit680b9610addf4ff1f004f038e709e16cfab1a947 (patch)
treeea80daf5a101f7f27805bc144e0d1c3d1c4124dc /gcc/ada/sem_ch5.adb
parent5ebae75fbcc5dce47bcfb3e72afd29db02f9fde6 (diff)
downloadgcc-680b9610addf4ff1f004f038e709e16cfab1a947.zip
gcc-680b9610addf4ff1f004f038e709e16cfab1a947.tar.gz
gcc-680b9610addf4ff1f004f038e709e16cfab1a947.tar.bz2
[Ada] Spurious warning on useless assignment with target name
gcc/ada/ * sem_ch5.adb (Analyze_Assignment): Do not emit the warning that a previous value of the target object is useless if the right-hand side of the assignment includes target names.
Diffstat (limited to 'gcc/ada/sem_ch5.adb')
-rw-r--r--gcc/ada/sem_ch5.adb7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index f03467f..0aef932 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -1108,6 +1108,12 @@ package body Sem_Ch5 is
-- warnings when an assignment is rewritten as another
-- assignment, and gets tied up with itself.
+ -- We also omit the warning if the RHS includes target names,
+ -- that is to say the Ada2020 "@" that denotes an instance of
+ -- the LHS, which indicates that the current value is being
+ -- used. Note that this implicit reference to the entity on
+ -- the RHS is not treated as a source reference.
+
-- There may have been a previous reference to a component of
-- the variable, which in general removes the Last_Assignment
-- field of the variable to indicate a relevant use of the
@@ -1126,6 +1132,7 @@ package body Sem_Ch5 is
and then Comes_From_Source (N)
and then In_Extended_Main_Source_Unit (Ent)
and then not Has_Deferred_Reference (Ent)
+ and then not Has_Target_Names (N)
then
Warn_On_Useless_Assignment (Ent, N);
end if;