diff mbox series

[COMMITTED,9/9] ada: Diagnose too large size clause on floating-point type

Message ID 20240902082430.1863631-9-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,1/9] ada: Remove repeated guards in validity checks | expand

Commit Message

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

The problem is that the size clause changes the floating-point format used
for the type, but it must not when this format is the widest format that is
supported in hardware on the target.  Instead a padding type must be built
and the associated warning given.

gcc/ada/

	* gcc-interface/decl.cc (gnat_to_gnu_entity): Cap the Esize of a
	floating-point type to the size of the widest format supported in
	hardware if it is explicity defined.

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

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

Patch

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index d7c17238bbc..398e01521a3 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -521,8 +521,12 @@  gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	  esize = UI_To_Int (Esize (gnat_entity));
 
 	  if (IN (kind, Float_Kind))
+#ifdef WIDEST_HARDWARE_FP_SIZE
+	    max_esize = fp_prec_to_size (WIDEST_HARDWARE_FP_SIZE);
+#else
 	    max_esize
 	      = fp_prec_to_size (TYPE_PRECISION (long_double_type_node));
+#endif
 	  else if (IN (kind, Access_Kind))
 	    max_esize = POINTER_SIZE * 2;
 	  else