]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Disable anonymous allocator warning for library-level objects
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Aug 2019 08:06:50 +0000 (08:06 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Aug 2019 08:06:50 +0000 (08:06 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274338 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/exp_ch4.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/anon3.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/anon3.ads [new file with mode: 0644]

index f4ad36d2dbe2f92cffbafc253142f5ac9656c527..5a9a9cced88399bf9794ba43b804409f943643ba 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * doc/gnat_ugn/building_executable_programs_with_gnat.rst
index 6f2fe32550743cef64c139513217a303136d7561..4404c5dca9da406107fd0a3ed1274602691a1cd6 100644 (file)
@@ -4421,10 +4421,13 @@ package body Exp_Ch4 is
 
    begin
       --  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
         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
          Error_Msg_N ("?use of an anonymous access type allocator", N);
       end if;
index 206d39d1c72316c4f68ef6227988ee5ac173c49e..8ec5ec02440d30812480d704a9ec1e213acfc9d3 100644 (file)
@@ -1,3 +1,7 @@
+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>
 
        * gnat.dg/generic_inst8.adb, gnat.dg/generic_inst8.ads,
diff --git a/gcc/testsuite/gnat.dg/anon3.adb b/gcc/testsuite/gnat.dg/anon3.adb
new file mode 100644 (file)
index 0000000..8628633
--- /dev/null
@@ -0,0 +1,6 @@
+--  { dg-do compile }
+--  { dg-options "-gnatwa" }
+
+package body Anon3 is
+   procedure Dummy is null;
+end Anon3;
diff --git a/gcc/testsuite/gnat.dg/anon3.ads b/gcc/testsuite/gnat.dg/anon3.ads
new file mode 100644 (file)
index 0000000..39978c2
--- /dev/null
@@ -0,0 +1,4 @@
+package Anon3 is
+   X : access Integer := new Integer;
+   procedure Dummy;
+end Anon3;