This fixes PR65555. As I already thought we should guard the noreturn-shouldn't-have-a-lhs checking properly so it doesn't apply to not yet discovered noreturn calls.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2015-03-26 Richard Biener <rguent...@suse.de> PR middle-end/65555 * tree-cfg.c (verify_gimple_call): Do not require a call to have no LHS if it wasn't recognized as control altering yet. * g++.dg/torture/pr65555.C: New testcase. Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 221690) +++ gcc/tree-cfg.c (working copy) @@ -3335,7 +3361,9 @@ verify_gimple_call (gcall *stmt) return true; } - if (gimple_call_lhs (stmt) && gimple_call_noreturn_p (stmt)) + if (gimple_call_ctrl_altering_p (stmt) + && gimple_call_lhs (stmt) + && gimple_call_noreturn_p (stmt)) { error ("LHS in noreturn call"); return true; Index: gcc/testsuite/g++.dg/torture/pr65555.C =================================================================== --- gcc/testsuite/g++.dg/torture/pr65555.C (revision 0) +++ gcc/testsuite/g++.dg/torture/pr65555.C (working copy) @@ -0,0 +1,11 @@ +// { dg-do compile } + +class basic_ostream { +public: + basic_ostream &operator<<(basic_ostream &p1(basic_ostream &)) { + return p1(*this); + } +} a; +void fn1() __attribute__((__noreturn__)); +basic_ostream &fn2(basic_ostream &) { fn1(); } +void fn3() { a << fn2; }