diff mbox series

[Ada] Fix internal error with Shift_Right operator on signed type

Message ID 14741341.c4fX3HzZOA@fomalhaut
State New
Headers show
Series [Ada] Fix internal error with Shift_Right operator on signed type | expand

Commit Message

Eric Botcazou Nov. 11, 2020, 12:56 p.m. UTC
This is a regression present on the mainline and 10 branch in the form of an 
ICE with a shift operator applied to a variable of a signed type, and which is 
caused by a type mismatch.

Tested on x86-64/Linux, applied on the mainline and 10 branch.


2020-11-11  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (gnat_to_gnu) <N_Op_Shift>: Also convert
	GNU_MAX_SHIFT if the type of the operation has been changed.


2020-11-11  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/shift1.adb: New test.
diff mbox series

Patch

diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 059e1a4f677..d0663a2d69b 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -7085,6 +7085,8 @@  gnat_to_gnu (Node_Id gnat_node)
 	    if (TREE_CODE (gnu_lhs) == INTEGER_CST && ignore_lhs_overflow)
 	      TREE_OVERFLOW (gnu_lhs) = TREE_OVERFLOW (gnu_old_lhs);
 	    gnu_rhs = convert (gnu_type, gnu_rhs);
+	    if (gnu_max_shift)
+	      gnu_max_shift = convert (gnu_type, gnu_max_shift);
 	  }
 
 	/* For signed integer addition, subtraction and multiplication, do an