[Ada] Assertion failure on validity check for Address
authorHristian Kirtchev <kirtchev@adacore.com>
Mon, 8 Jul 2019 08:14:27 +0000 (08:14 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 8 Jul 2019 08:14:27 +0000 (08:14 +0000)
This patch corrects the verification of 'Address clauses to avoid
processing a clause where the prefix of the attribute is a generic
formal object.

2019-07-08  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Do not
register an address clause when its prefix denotes a generic
formal object.

gcc/testsuite/

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

From-SVN: r273218

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

index cc8978d79184a18c4fc62c79ac68faa4cbaeb019..b1224281640920902bf8a39cfd2da30999467d34 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-08  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * sem_ch13.adb (Analyze_Attribute_Definition_Clause): Do not
+       register an address clause when its prefix denotes a generic
+       formal object.
+
 2019-07-08  Hristian Kirtchev  <kirtchev@adacore.com>
 
        * bindo-diagnostics.adb (Diagnose_Cycle): Capture the presence
index 76639cd301fc5a3608ef701392e130bc59d79845..cbae9c8d4a34d9292ed88f6f57d9cceabd16662c 100644 (file)
@@ -5145,6 +5145,7 @@ package body Sem_Ch13 is
                      --  aspect case properly.
 
                      if Is_Object (O_Ent)
+                       and then not Is_Generic_Formal (O_Ent)
                        and then not Is_Generic_Type (Etype (U_Ent))
                        and then Address_Clause_Overlay_Warnings
                      then
index 25f6636f5f21b23b35dad740a4516408833d70f3..169c7a58193a490babedaebc2a15380c3928ba3c 100644 (file)
@@ -1,3 +1,7 @@
+2019-07-08  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * gnat.dg/addr13.adb, gnat.dg/addr13.ads: New testcase.
+
 2019-07-08  Ed Schonberg  <schonberg@adacore.com>
 
        * gnat.dg/entry1.adb, gnat.dg/entry1.ads: New testcase.
diff --git a/gcc/testsuite/gnat.dg/addr13.adb b/gcc/testsuite/gnat.dg/addr13.adb
new file mode 100644 (file)
index 0000000..91e44ae
--- /dev/null
@@ -0,0 +1,9 @@
+--  { dg-do compile }
+
+package body Addr13 is
+   procedure Overlay is
+      Over : Integer with Address => Gen_Obj'Address;
+   begin
+      Over := 123;
+   end Overlay;
+end Addr13;
diff --git a/gcc/testsuite/gnat.dg/addr13.ads b/gcc/testsuite/gnat.dg/addr13.ads
new file mode 100644 (file)
index 0000000..f1f1646
--- /dev/null
@@ -0,0 +1,5 @@
+generic
+   Gen_Obj : in out Integer;
+package Addr13 is
+   procedure Overlay;
+end Addr13;