https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99198

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-checking
   Last reconfirmed|                            |2021-02-22

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we verify

  /* If there is a static chain argument, the call should either be
     indirect, or the decl should have DECL_STATIC_CHAIN set.  */
  if (gimple_call_chain (stmt)
      && fndecl
      && !DECL_STATIC_CHAIN (fndecl))
    {
      error ("static chain with function that doesn%'t use one");
      return true;
    }

and when changing the testcase to

int main() {
    void f() {}
    void (*g)() = f;
    __builtin_call_with_static_chain(g(), &f);

    return 0;
}

CCP properly clears the static chain when propagating 'f'.  Thus folding
of __builtin_call_with_static_chain should properly do the same.

Reply via email to