[PATCH] Fix ICE in expand_shift

Jakub Jelinek jakub@redhat.com
Fri Oct 27 07:03:00 GMT 2000


Hi!

The following testcase ICEs in expand_shift. The reason is that inlining on
trees replaces y with 0x07 const_int and do_store_flag was passing VOIDmode
to expand_shift. The patch below passes in that case operand_mode instead
(that is the mode of the BIT_AND_EXPR).

2000-10-27  Jakub Jelinek  <jakub@redhat.com>

	* expr.c (do_store_flag): If op0 has mode VOIDmode, pass operand_mode
	instead to expand_shift.

	* g++.old-deja/g++.other/inline16.C: New test.

--- gcc/testsuite/g++.old-deja/g++.other/inline16.C.jj	Fri Oct 27 15:57:15 2000
+++ gcc/testsuite/g++.old-deja/g++.other/inline16.C	Mon Oct 23 16:06:58 2000
@@ -0,0 +1,24 @@
+// Build don't link:
+// Origin: Jakub Jelinek <jakub@redhat.com>
+// Special g++ Options: -O1
+
+struct foo {
+  bool x;
+  inline void a (unsigned char y);
+  inline void b (void);
+  virtual ~foo ();
+};
+
+foo::~foo ()
+{
+}
+
+void foo::a (unsigned char y)
+{
+    x = ((y & 2) != 0);
+}
+
+void foo::b (void)
+{
+    a(0x07);
+}
--- gcc/expr.c.jj	Fri Oct 27 13:34:59 2000
+++ gcc/expr.c	Fri Oct 27 15:54:34 2000
@@ -10285,7 +10285,9 @@ do_store_flag (exp, target, mode, only_c
       op0 = expand_expr (inner, subtarget, VOIDmode, 0);
 
       if (bitnum != 0)
-	op0 = expand_shift (RSHIFT_EXPR, GET_MODE (op0), op0,
+	op0 = expand_shift (RSHIFT_EXPR,
+			    GET_MODE (op0) == VOIDmode
+			    ? operand_mode : GET_MODE (op0), op0,
 			    size_int (bitnum), subtarget, ops_unsignedp);
 
       if (GET_MODE (op0) != mode)

	Jakub


More information about the Gcc-patches mailing list