Hi! As described in the PR, while build_function_decl_skip_args takes care of changing the type from METHOD_TYPE to FUNCTION_TYPE if removing first argument (this), the FE may have other special arguments that it is aware of (such as in-charge etc.) and if the this argument is not removed, but the other arguments are, then the FE can crash upon seeing such methods.
Fixed by clearing DECL_LANG_SPECIFIC if we remove any arguments. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2014-02-04 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/60002 * cgraphclones.c (build_function_decl_skip_args): Clear DECL_LANG_SPECIFIC. * g++.dg/opt/pr60002.C: New test. --- gcc/cgraphclones.c.jj 2014-01-31 22:21:42.911750272 +0100 +++ gcc/cgraphclones.c 2014-02-03 19:43:30.678941701 +0100 @@ -390,6 +390,9 @@ build_function_decl_skip_args (tree orig DECL_BUILT_IN_CLASS (new_decl) = NOT_BUILT_IN; DECL_FUNCTION_CODE (new_decl) = (enum built_in_function) 0; } + /* The FE might have information and assumptions about the other + arguments. */ + DECL_LANG_SPECIFIC (new_decl) = NULL; return new_decl; } --- gcc/testsuite/g++.dg/opt/pr60002.C.jj 2014-02-03 19:43:47.671856267 +0100 +++ gcc/testsuite/g++.dg/opt/pr60002.C 2014-02-03 19:43:00.000000000 +0100 @@ -0,0 +1,12 @@ +// PR tree-optimization/60002 +// { dg-do compile } +// { dg-options "-O2 -fcompare-debug -fdeclone-ctor-dtor -fipa-cp-clone" } + +struct A {}; + +struct B : virtual A { B (); ~B (); }; + +B::~B () +{ + B (); +} Jakub