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.
gcc/ada/ChangeLog:
* gcc-interface/trans.c (gnat_to_gnu) <N_Op_Shift>: Also convert
GNU_MAX_SHIFT if the type of the operation has been changed.
* gcc-interface/utils.c (can_materialize_object_renaming_p): Add
pair of missing parentheses.
gcc/testsuite/ChangeLog:
* gnat.dg/shift1.adb: New test.
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
{
expr = Original_Node (expr);
- switch Nkind (expr)
+ switch (Nkind (expr))
{
case N_Identifier:
case N_Expanded_Name:
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-gnatws" }
+
+procedure Shift1 is
+
+ type T_Integer_8 is range -2 ** 7 .. 2 ** 7 - 1
+ with Size => 8;
+
+ pragma Provide_Shift_Operators (T_Integer_8);
+
+ X : T_Integer_8;
+
+begin
+ X := Shift_Right (X, 1);
+end;