public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix for internal error on semi-circular record aggregate
@ 2022-05-19 14:16 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-19 14:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

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

This creates a couple of record subtypes pointing to each other through
access subtypes, and we break the circularity at the latter subtypes.

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

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.

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

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
--- 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;



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

only message in thread, other threads:[~2022-05-19 14:16 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:16 [Ada] Fix for internal error on semi-circular record aggregate 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).