public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Steve Baird <baird@adacore.com>
Subject: [Ada] Internal error compiling formal instance of generic with Initial_Condition
Date: Mon, 12 Sep 2022 10:19:31 +0200	[thread overview]
Message-ID: <20220912081931.GA1512981@poulhies-Precision-5550> (raw)

[-- 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;



                 reply	other threads:[~2022-09-12  8:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220912081931.GA1512981@poulhies-Precision-5550 \
    --to=poulhies@adacore.com \
    --cc=baird@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).