public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-662] [Ada] Fix internal error on semi-circular record types
@ 2022-05-19 14:08 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-19 14:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:795f74c735627f4215f18174e761c6b5b9098449

commit r13-662-g795f74c735627f4215f18174e761c6b5b9098449
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed Feb 16 18:07:26 2022 +0100

    [Ada] Fix internal error on semi-circular record types
    
    The front-end properly computes a linear elaboration order for them, but
    there was a loophole in the handling of the delayed case.
    
    gcc/ada/
    
            * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Access_Subtype>: And
            skip the elaboration of the designated subtype when that of its base
            type has been delayed.

Diff:
---
 gcc/ada/gcc-interface/decl.cc | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 075a7ebd372..aa8736c7a86 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -3846,17 +3846,18 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
       maybe_present = true;
 
       /* The designated subtype must be elaborated as well, if it does
-	 not have its own freeze node.  But designated subtypes created
-	 for constrained components of records with discriminants are
-	 not frozen by the front-end and not elaborated here, because
-	 their use may appear before the base type is frozen and it is
-	 not clear that they are needed in gigi.  With the current model,
-	 there is no correct place where they could be elaborated.  */
+	 not have its own freeze node.  */
       if (Is_Itype (Directly_Designated_Type (gnat_entity))
 	  && !present_gnu_tree (Directly_Designated_Type (gnat_entity))
 	  && Is_Frozen (Directly_Designated_Type (gnat_entity))
 	  && No (Freeze_Node (Directly_Designated_Type (gnat_entity))))
 	{
+	  tree gnu_base_type = TREE_TYPE (gnu_decl);
+	  tree gnu_desig_base_type
+	    = TYPE_IS_FAT_POINTER_P (gnu_base_type)
+	      ? TREE_TYPE (TREE_TYPE (TYPE_FIELDS (gnu_base_type)))
+	      : TREE_TYPE (gnu_base_type);
+
 	  /* If we are to defer elaborating incomplete types, make a dummy
 	     type node and elaborate it later.  */
 	  if (defer_incomplete_level != 0)
@@ -3869,8 +3870,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	      p->next = defer_incomplete_list;
 	      defer_incomplete_list = p;
 	    }
-	  else if (!Is_Incomplete_Or_Private_Type
-		      (Base_Type (Directly_Designated_Type (gnat_entity))))
+
+	  /* Otherwise elaborate the designated subtype only if its base type
+	     has already been elaborated.  */
+	  else if (!TYPE_IS_DUMMY_P (gnu_desig_base_type))
 	    gnat_to_gnu_entity (Directly_Designated_Type (gnat_entity),
 				NULL_TREE, false);
 	}


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

only message in thread, other threads:[~2022-05-19 14:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 14:08 [gcc r13-662] [Ada] Fix internal error on semi-circular record types 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).