Commit 943c82d7 by Justin Squirek Committed by Pierre-Marie de Rodat

[Ada] Disable anonymous allocator warning for library-level objects

This patch modifies the behavior of anonymous allocator warnings so that
they no longer get triggered in the case of an object declaration at
library-level.

2019-08-13  Justin Squirek  <squirek@adacore.com>

gcc/ada/

	* exp_ch4.adb (Expand_N_Allocator): Add condition to detect
	library-level object declarations

gcc/testsuite/

	* gnat.dg/anon3.adb, gnat.dg/anon3.ads: New testcase.

From-SVN: r274338
parent 114042b8
2019-08-13 Justin Squirek <squirek@adacore.com>
* exp_ch4.adb (Expand_N_Allocator): Add condition to detect
library-level object declarations
2019-08-13 Eric Botcazou <ebotcazou@adacore.com> 2019-08-13 Eric Botcazou <ebotcazou@adacore.com>
* doc/gnat_ugn/building_executable_programs_with_gnat.rst * doc/gnat_ugn/building_executable_programs_with_gnat.rst
......
...@@ -4421,10 +4421,13 @@ package body Exp_Ch4 is ...@@ -4421,10 +4421,13 @@ package body Exp_Ch4 is
begin begin
-- Warn on the presence of an allocator of an anonymous access type when -- Warn on the presence of an allocator of an anonymous access type when
-- enabled. -- enabled except when its an object declaration at library level.
if Warn_On_Anonymous_Allocators if Warn_On_Anonymous_Allocators
and then Ekind (PtrT) = E_Anonymous_Access_Type and then Ekind (PtrT) = E_Anonymous_Access_Type
and then not (Is_Library_Level_Entity (PtrT)
and then Nkind (Associated_Node_For_Itype (PtrT)) =
N_Object_Declaration)
then then
Error_Msg_N ("?use of an anonymous access type allocator", N); Error_Msg_N ("?use of an anonymous access type allocator", N);
end if; end if;
......
2019-08-13 Justin Squirek <squirek@adacore.com>
* gnat.dg/anon3.adb, gnat.dg/anon3.ads: New testcase.
2019-08-13 Eric Botcazou <ebotcazou@adacore.com> 2019-08-13 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/generic_inst8.adb, gnat.dg/generic_inst8.ads, * gnat.dg/generic_inst8.adb, gnat.dg/generic_inst8.ads,
......
-- { dg-do compile }
-- { dg-options "-gnatwa" }
package body Anon3 is
procedure Dummy is null;
end Anon3;
package Anon3 is
X : access Integer := new Integer;
procedure Dummy;
end Anon3;
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