From b713a445f2bfa00419e7efdb5ffc0cf89e335227 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Thu, 24 Jun 2004 06:51:56 +0000 Subject: [PATCH] re PR middle-end/15988 (ICE in fold_convert with pointer-to-member-function) 2004-06-23 Andrew Pinski 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 PR middle-end/15988 * g++.dg/opt/ptrmem4.C: New test. From-SVN: r83585 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 4 +++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/opt/ptrmem4.C | 12 ++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/opt/ptrmem4.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eb04bf36dc0..6d23ff919c3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-06-23 Andrew Pinski + + 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 * calls.c (expand_call): Call INIT_CUMULATIVE_ARGS earlier, and diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 0dd5973d55d..6ef7b1a9532 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index facc58b22eb..d46e6732c9a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2004-06-23 Andrew Pinski + 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 diff --git a/gcc/testsuite/g++.dg/opt/ptrmem4.C b/gcc/testsuite/g++.dg/opt/ptrmem4.C new file mode 100644 index 00000000000..2ca34f4d13d --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/ptrmem4.C @@ -0,0 +1,12 @@ +// { dg-do run } +// { dg-options "-O3" } + +struct X { void foo (); }; + +template +inline void spawn (void (X::*fun_ptr)()) {} + +void bar () { + void (X::*const comp)() = &X::foo; + spawn (comp); +} -- 2.30.2