public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-4915] Fix internal error with Shift_Right operator on signed type
@ 2020-11-11 12:55 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2020-11-11 12:55 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1f8fc1f458c4a66618c35d8e292fff6e9dce9f12
commit r11-4915-g1f8fc1f458c4a66618c35d8e292fff6e9dce9f12
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Wed Nov 11 13:53:01 2020 +0100
Fix internal error with Shift_Right operator on signed type
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.
Diff:
---
gcc/ada/gcc-interface/trans.c | 2 ++
gcc/ada/gcc-interface/utils.c | 2 +-
gcc/testsuite/gnat.dg/shift1.adb | 15 +++++++++++++++
3 files changed, 18 insertions(+), 1 deletion(-)
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
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index d50872f81b0..dfde06e48c1 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -5837,7 +5837,7 @@ can_materialize_object_renaming_p (Node_Id expr)
{
expr = Original_Node (expr);
- switch Nkind (expr)
+ switch (Nkind (expr))
{
case N_Identifier:
case N_Expanded_Name:
diff --git a/gcc/testsuite/gnat.dg/shift1.adb b/gcc/testsuite/gnat.dg/shift1.adb
new file mode 100644
index 00000000000..85a0fecdae4
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/shift1.adb
@@ -0,0 +1,15 @@
+-- { 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-11 12:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 12:55 [gcc r11-4915] Fix internal error with Shift_Right operator on signed type Eric Botcazou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).