public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-661] [Ada] Fix for internal error on semi-circular record aggregate
Date: Thu, 19 May 2022 14:08:36 +0000 (GMT)	[thread overview]
Message-ID: <20220519140836.BDAB2383F85A@sourceware.org> (raw)

https://gcc.gnu.org/g:dfbdd4b9812b199a74dbb948b4eb54fb7bb30883

commit r13-661-gdfbdd4b9812b199a74dbb948b4eb54fb7bb30883
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Thu Feb 10 12:37:56 2022 +0100

    [Ada] Fix for internal error on semi-circular record aggregate
    
    This creates a couple of record subtypes pointing to each other through
    access subtypes, and we break the circularity at the latter subtypes.
    
    gcc/ada/
    
            * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: If
            it is a special subtype designated by an access subtype, then defer
            the completion of incomplete types.

Diff:
---
 gcc/ada/gcc-interface/decl.cc | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index c096b0d08d3..075a7ebd372 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -2134,6 +2134,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	   suppress expanding incomplete types.  */
 	gnu_type = make_node (UNCONSTRAINED_ARRAY_TYPE);
 
+	/* The component may refer to this type, so defer completion of any
+	   incomplete types.  */
 	if (!definition)
 	  {
 	    defer_incomplete_level++;
@@ -3066,7 +3068,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 
 	process_attributes (&gnu_type, &attr_list, true, gnat_entity);
 
-	/* If we are not defining it, suppress expanding incomplete types.  */
+	/* Some component may refer to this type, so defer completion of any
+	   incomplete types.  */
 	if (!definition)
 	  {
 	    defer_incomplete_level++;
@@ -3439,7 +3442,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	{
 	  Entity_Id gnat_base_type = Implementation_Base_Type (gnat_entity);
 
-	  if (!definition)
+	  /* Some component may refer to this type, so defer completion of any
+	     incomplete types.  We also need to do it for the special subtypes
+	     designated by access subtypes in case they are recursive, see the
+	     E_Access_Subtype case below.  */
+	  if (!definition
+	      || (Is_Itype (gnat_entity)
+		  && Is_Frozen (gnat_entity)
+		  && No (Freeze_Node (gnat_entity))))
 	    {
 	      defer_incomplete_level++;
 	      this_deferred = true;


                 reply	other threads:[~2022-05-19 14:08 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=20220519140836.BDAB2383F85A@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@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).