re PR middle-end/15988 (ICE in fold_convert with pointer-to-member-function)
authorAndrew Pinski <apinski@apple.com>
Thu, 24 Jun 2004 06:51:56 +0000 (06:51 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Thu, 24 Jun 2004 06:51:56 +0000 (23:51 -0700)
2004-06-23  Andrew Pinski  <apinski@apple.com>

        PR middle-end/15988
        * fold-const.c (fold_convert): Types which are compatible
        can be converted with only a NOP_EXPR.

2004-06-23  Andrew Pinski  <apinski@apple.com>

        PR middle-end/15988
        * g++.dg/opt/ptrmem4.C: New test.

From-SVN: r83585

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/ptrmem4.C [new file with mode: 0644]

index eb04bf36dc06796a558e048e95a28355f746eda0..6d23ff919c33b0c696c14110422dc7c5fb9c7bbc 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-23  Andrew Pinski  <apinski@apple.com>
+
+       PR middle-end/15988
+       * fold-const.c (fold_convert): Types which are compatible
+       can be converted with only a NOP_EXPR.
+
 2004-06-24  Alan Modra  <amodra@bigpond.net.au>
 
        * calls.c (expand_call): Call INIT_CUMULATIVE_ARGS earlier, and
index 0dd5973d55d248b743fbac90e71111b218a197e3..6ef7b1a953219fdac4800c8e7232764c672f1653 100644 (file)
@@ -1907,7 +1907,9 @@ fold_convert (tree type, tree arg)
       || TREE_CODE (orig) == ERROR_MARK)
     return error_mark_node;
 
-  if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig))
+  if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig)
+      || lang_hooks.types_compatible_p (TYPE_MAIN_VARIANT (type),
+                                       TYPE_MAIN_VARIANT (orig)))
     return fold (build1 (NOP_EXPR, type, arg));
 
   if (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type)
index facc58b22eb322a6daba1a5f75999549cbdcc04a..d46e6732c9a55207f057aa2066b4f848b205797e 100644 (file)
@@ -1,5 +1,8 @@
 2004-06-23  Andrew Pinski  <apinski@apple.com>
 
+       PR middle-end/15988
+       * g++.dg/opt/ptrmem4.C: New test.
+
        * gcc.dg/c90-array-quals-2.c: New test.
 
 2006-06-23  Nitin Yewale <NitinY@KPITCummins.com>
diff --git a/gcc/testsuite/g++.dg/opt/ptrmem4.C b/gcc/testsuite/g++.dg/opt/ptrmem4.C
new file mode 100644 (file)
index 0000000..2ca34f4
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do run }
+// { dg-options "-O3" }
+
+struct X { void foo (); }; 
+template <typename> 
+inline void spawn (void (X::*fun_ptr)()) {} 
+void bar () { 
+  void (X::*const comp)() = &X::foo; 
+  spawn<int> (comp); 
+}