public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Internal error compiling formal instance of generic with Initial_Condition
@ 2022-09-12  8:19 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2022-09-12  8:19 UTC (permalink / raw)
  To: gcc-patches; +Cc: Steve Baird

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

Prevent the compiler from failing with an internal error in some cases involving
an instance of a generic which takes as a formal parameter an instance of a
second generic, where the second generic has an Initial_Condition aspect
specification.

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

gcc/ada/

	* contracts.adb
	(Analyze_Package_Contract): Do not analyze the contract of a
	temporary package created just to check conformance of an actual
	package.

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

diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb
--- a/gcc/ada/contracts.adb
+++ b/gcc/ada/contracts.adb
@@ -1319,6 +1319,18 @@ package body Contracts is
       if Present (Items) then
          if Analyzed (Items) then
             return;
+
+         --  Do not analyze the contract of the internal package
+         --  created to check conformance of an actual package.
+         --  Such an internal package is removed from the tree after
+         --  legality checks are completed, and it does not contain
+         --  the declarations of all local entities of the generic.
+
+         elsif Is_Internal (Pack_Id)
+           and then Is_Generic_Instance (Pack_Id)
+         then
+            return;
+
          else
             Set_Analyzed (Items);
          end if;



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

only message in thread, other threads:[~2022-09-12  8:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12  8:19 [Ada] Internal error compiling formal instance of generic with Initial_Condition Marc Poulhiès

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).