diff mbox series

[COMMITTED,09/10] ada: Plug loophole exposed by previous change

Message ID 20240903082102.2268026-9-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/10] ada: Fix Finalize_Storage_Only bug in b-i-p calls | expand

Commit Message

Marc Poulhiès Sept. 3, 2024, 8:21 a.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>

The change causes more temporaries to be created at call sites for unaligned
actual parameters, thus revealing that the machinery does not properly deal
with unconstrained nominal subtypes for them.

gcc/ada/

	* gcc-interface/trans.cc (create_temporary): Deal with types whose
	size is self-referential by allocating the maximum size.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/gcc-interface/trans.cc | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index caa0f56a34d..fadd6b483d5 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -4527,6 +4527,9 @@  storage_model_access_required_p (Node_Id gnat_node, Entity_Id *gnat_smo)
 static tree
 create_temporary (const char *prefix, tree type)
 {
+  if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type)))
+    type = maybe_pad_type (type, max_size (TYPE_SIZE (type), true), 0,
+			   Empty, false, false, true);
   tree gnu_temp
     = create_var_decl (create_tmp_var_name (prefix), NULL_TREE,
 		      type, NULL_TREE,