diff mbox series

[COMMITTED,06/10] ada: Fix internal error on pragma pack with discriminated record component

Message ID 20240903082102.2268026-6-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:20 a.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>

When updating the size after making a packable type in gnat_to_gnu_field,
we fail to clear it again when it is not constant.

gcc/ada/

	* gcc-interface/decl.cc (gnat_to_gnu_field): Clear again gnu_size
	after updating it if it is not constant.

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

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

Patch

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 398e01521a3..655ba0b8a10 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -7686,6 +7686,8 @@  gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
 	  gnu_field_type = gnu_packable_type;
 	  if (!gnu_size)
 	    gnu_size = rm_size (gnu_field_type);
+	  if (TREE_CODE (gnu_size) != INTEGER_CST)
+	    gnu_size = NULL_TREE;
 	}
     }