summaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2019-10-10 15:25:13 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-10-10 15:25:13 +0000
commit4e866f08452aee2747a93f416ff1eb7b86d9f32e (patch)
tree29ff2c09c661367728c90259beb3afebfe3cb45d /gcc/ada
parent6c142b14a07b166fcb2809cd3c3fcd59a748ce7e (diff)
downloadgcc-4e866f08452aee2747a93f416ff1eb7b86d9f32e.tar.gz
[Ada] Spurious warning on call with out parameter in expression function
2019-10-10 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_warn.adb (Warn_On_Useless_Assignment): Do not warn if the second assignment is at the same source position as the first. From-SVN: r276831
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog10
-rw-r--r--gcc/ada/sem_warn.adb6
2 files changed, 9 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 9cf51728022..24c831e5b90 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,8 +1,4 @@
-2019-10-10 Gary Dismukes <dismukes@adacore.com>
+2019-10-10 Ed Schonberg <schonberg@adacore.com>
- * sem_util.adb (Enclosing_Subprogram): Handle the case of
- E_Entry_Family, returning the entry family's associated
- Protected_Body_Subprogram (as was already done for E_Entry).
- * exp_ch9.adb (Expand_N_Accept_Statement): Call Reset_Scopes_To
- on the block created for an accept statement to reset the scopes
- of any local entities to the block scope. \ No newline at end of file
+ * sem_warn.adb (Warn_On_Useless_Assignment): Do not warn if the
+ second assignment is at the same source position as the first. \ No newline at end of file
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index f9a6062c092..04e7acfb65e 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -4546,9 +4546,15 @@ package body Sem_Warn is
-- to capture the value. We are not going to capture any value, but
-- the warning message depends on the same kind of conditions.
+ -- If the assignment appears as an out-parameter in a call within an
+ -- expression function it may be detected twice: once when expression
+ -- itself is analyzed, and once when the constructed body is analyzed.
+ -- We don't want to emit a spurious warning in this case.
+
if Is_Assignable (Ent)
and then not Is_Return_Object (Ent)
and then Present (Last_Assignment (Ent))
+ and then Last_Assignment (Ent) /= N
and then not Is_Imported (Ent)
and then not Is_Exported (Ent)
and then Safe_To_Capture_Value (N, Ent)