Commit 4e866f08 by Ed Schonberg Committed by Pierre-Marie de Rodat

[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
parent 6c142b14
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 * sem_warn.adb (Warn_On_Useless_Assignment): Do not warn if the
E_Entry_Family, returning the entry family's associated second assignment is at the same source position as the first.
Protected_Body_Subprogram (as was already done for E_Entry). \ No newline at end of file
* 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
...@@ -4546,9 +4546,15 @@ package body Sem_Warn is ...@@ -4546,9 +4546,15 @@ package body Sem_Warn is
-- to capture the value. We are not going to capture any value, but -- to capture the value. We are not going to capture any value, but
-- the warning message depends on the same kind of conditions. -- 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) if Is_Assignable (Ent)
and then not Is_Return_Object (Ent) and then not Is_Return_Object (Ent)
and then Present (Last_Assignment (Ent)) and then Present (Last_Assignment (Ent))
and then Last_Assignment (Ent) /= N
and then not Is_Imported (Ent) and then not Is_Imported (Ent)
and then not Is_Exported (Ent) and then not Is_Exported (Ent)
and then Safe_To_Capture_Value (N, Ent) and then Safe_To_Capture_Value (N, Ent)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment