This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Fix ICE in gimplify_conversion (PR c++/40780)


Hi!

Earlier actions in gimplify_conversion might turn a NOP_EXPR or CONVERT_EXPR
into something else (in this testcase PTRMEM_CST), for which TREE_OPERAND
doesn't apply.  Most of the if clauses in gimplify_conversion already verify
that it is still looking at CONVERT_EXPR_P before doing anything, but this
one newly added for 4.4.0 does not.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk and 4.4 branch.

2009-07-17  Jakub Jelinek  <jakub@redhat.com>

	PR c++/40780
	* gimplify.c (gimplify_conversion): Don't change non-conversions into
	VIEW_CONVERT_EXPR.

	* g++.dg/template/ptrmem19.C: New test.

--- gcc/gimplify.c.jj	2009-07-08 11:28:03.000000000 +0200
+++ gcc/gimplify.c	2009-07-17 10:40:56.000000000 +0200
@@ -1827,9 +1827,9 @@ gimplify_conversion (tree *expr_p)
 
   /* If we have a conversion to a non-register type force the
      use of a VIEW_CONVERT_EXPR instead.  */
-  if (!is_gimple_reg_type (TREE_TYPE (*expr_p)))
+  if (CONVERT_EXPR_P (*expr_p) && !is_gimple_reg_type (TREE_TYPE (*expr_p)))
     *expr_p = fold_build1_loc (loc, VIEW_CONVERT_EXPR, TREE_TYPE (*expr_p),
-			   TREE_OPERAND (*expr_p, 0));
+			       TREE_OPERAND (*expr_p, 0));
 
   return GS_OK;
 }
--- gcc/testsuite/g++.dg/template/ptrmem19.C.jj	2009-07-17 11:04:26.000000000 +0200
+++ gcc/testsuite/g++.dg/template/ptrmem19.C	2009-07-17 11:05:06.000000000 +0200
@@ -0,0 +1,19 @@
+// PR c++/40780
+// { dg-do compile }
+
+template <class T1, typename T2, typename T3>
+struct A
+{
+  typedef T2 (T1::*m) (T3);
+  A (m) {}
+};
+struct B;
+struct C
+{
+  void foo (B *);
+};
+typedef A <C, void, B *> D;
+typedef void (C::*E) (B *);
+struct F;
+typedef void (C::*G) (F);
+D d ((E) (G) & C::foo);

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]