On Wed, Mar 28, 2018 at 2:18 AM, Alexandre Oliva <aol...@redhat.com> wrote: > On Mar 23, 2018, Jason Merrill <ja...@redhat.com> wrote: > >> On Fri, Mar 23, 2018 at 4:55 PM, Jason Merrill <ja...@redhat.com> wrote: >>> On Fri, Mar 23, 2018 at 12:44 PM, Jason Merrill <ja...@redhat.com> wrote: >>>> Seems like cp_fold should update CALL_EXPR_FN with "callee" if non-null. >>> >>> Did you try this? That should avoid it being ADDR_EXPR of a decl. > >> Oh, I was assuming the ICE was in the middle-end, but it's in >> build_call_a. And it looks like the problem isn't that it's an >> ADDR_EXPR of a decl, but that the function isn't marked TREE_USED. > > Well, yeah. cp_build_function_call_vec marks the function as used when > function is a FUNCTION_DECL. In this testcase, it's INDIRECT_REF of > ADDR_EXPR of FUNCTION_DECL.
It should have been marked as used before we get to cp_build_function_call_vec. finish_id_expression doesn't mark it because "done" is false, because we're in a postfix-expression. It looks like cp_build_addr_expr_1 already calls mark_used for single static member functions, it should probably do the same for single non-member functions. Jason