diff mbox series

[Ada] Fix internal error on function returning dynamically-sized type

Message ID 4874875.31r3eYUQgx@fomalhaut
State New
Headers show
Series [Ada] Fix internal error on function returning dynamically-sized type | expand

Commit Message

Eric Botcazou Nov. 16, 2023, 5:36 p.m. UTC
This is PR ada/109881, a tree sharing issue for the internal return type 
synthesized for a function returning a dynamically-sized type and taking an 
Out or In/Out parameter passed by copy.

Tested on x86-64/Linux, applied on mainline, 13 and 12 branches.


2023-11-16  Eric Botcazou  <ebotcazou@adacore.com>

	PR ada/109881
	* gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Also create a
	TYPE_DECL for the return type built for the CI/CO mechanism.


2023-11-16  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/varsize4.ads, gnat.dg/varsize4.adb: New test.
	* gnat.dg/varsize4_pkg.ads: New helper.
diff mbox series

Patch

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 95fa508c559..9c7f6840e21 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -6329,6 +6329,12 @@  gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
 
 	  if (debug_info_p)
 	    rest_of_record_type_compilation (gnu_cico_return_type);
+
+	  /* Declare it now since it will never be declared otherwise.  This
+	     is necessary to ensure that its subtrees are properly marked.  */
+	  create_type_decl (TYPE_NAME (gnu_cico_return_type),
+			    gnu_cico_return_type,
+			    true, debug_info_p, gnat_subprog);
 	}
 
       gnu_return_type = gnu_cico_return_type;