public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Compiler crash with -gnatR2 and with of child
@ 2022-01-05 11:33 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-01-05 11:33 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bob Duff

[-- Attachment #1: Type: text/plain, Size: 622 bytes --]

This patch fixes a bug where if a parent library package contains a with
clause that mentions a child of that same parent package, then gnat can
crash if the parent package is compiled with the -gnatR2 switch.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* repinfo.adb (List_Entities): The code was assuming that if we
	encounter a package in the current scope, then it must be
	a (physically) nested package.  That was wrong, because it could
	be a child package.  Avoid recursing into child packages; they
	have not been annotated with representation information, and
	-gnatR2 queries that information.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 999 bytes --]

diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb
--- a/gcc/ada/repinfo.adb
+++ b/gcc/ada/repinfo.adb
@@ -568,12 +568,14 @@ package body Repinfo is
                   end if;
                end if;
 
-               --  Recurse into nested package, but not if they are package
-               --  renamings (in particular renamings of the enclosing package,
-               --  as for some Java bindings and for generic instances).
+               --  Recurse into nested package, but not child packages, and not
+               --  nested package renamings (in particular renamings of the
+               --  enclosing package, as for some Java bindings and for generic
+               --  instances).
 
                if Ekind (E) = E_Package then
-                  if No (Renamed_Entity (E)) then
+                  if No (Renamed_Entity (E)) and then not Is_Child_Unit (E)
+                  then
                      List_Entities (E, Bytes_Big_Endian);
                   end if;
 



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-05 11:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 11:33 [Ada] Compiler crash with -gnatR2 and with of child Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).