diff mbox series

[RISC-V] Fix PR target/115591

Message ID 2331579.ElGaqSPkdT@fomalhaut
State New
Headers show
Series [RISC-V] Fix PR target/115591 | expand

Commit Message

Eric Botcazou July 6, 2024, 10 a.m. UTC
This is an ICE in the RISC-V back-end calling tree_to_uhwi on the DECL_SIZE of 
a global variable-length array.  Fixed thusly, tested and approved by Jeff in 
the audit trail, and applied on the mainline.


2024-07-06  Eric Botcazou  <ebotcazou@adacore.com>

	PR target/115591
	* config/riscv/riscv.cc (riscv_valid_lo_sum_p): Add missing test on
	tree_fits_uhwi_p before calling tree_to_uhwi.


2024-07-06  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/array41.ads, gnat.dg/array41.adb: New test.
diff mbox series

Patch

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index c17141d909a..5e34dc92210 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -1702,7 +1702,9 @@  riscv_valid_lo_sum_p (enum riscv_symbol_type sym_type, machine_mode mode,
       align = (SYMBOL_REF_DECL (x)
 	       ? DECL_ALIGN (SYMBOL_REF_DECL (x))
 	       : 1);
-      size = (SYMBOL_REF_DECL (x) && DECL_SIZE (SYMBOL_REF_DECL (x))
+      size = (SYMBOL_REF_DECL (x)
+	      && DECL_SIZE (SYMBOL_REF_DECL (x))
+	      && tree_fits_uhwi_p (DECL_SIZE (SYMBOL_REF_DECL (x)))
 	      ? tree_to_uhwi (DECL_SIZE (SYMBOL_REF_DECL (x)))
 	      : 2*BITS_PER_WORD);
     }