On 10/1/26 8:10 AM, Jakub Jelinek wrote:
Hi!

The following testcases ICE during mangling, the dependent
__builtin_{bswap,bitreverse}g calls (where those identifiers
we treat as keywords and don't even have such builtins,
given that those are the first type-generic builtins with the
return type dependent on the argument type(s)) are emitted
as internal fn calls (IFN_BSWAP or IFN_BITREVERSE), and
during mangling we just ICE on any calls to internal functions.

The following patch mangles those 2 calls like we mangle e.g.
template <typename T>
auto foo (T t) -> decltype (__builtin_popcountg (t)) { return t; }

template int foo <unsigned> (unsigned);
- _Z3fooIjEDTcl19__builtin_popcountgfp_EET_ .  In
that case it is a type-generic builtin with a fixed return
type and we trigger the
   /* Mangle a dependent name as the name, not whatever happens to
      be the first function in the overload set.  */
   if (OVL_P (fn)
       && type_dependent_expression_p_push (expr))
     fn = OVL_NAME (fn);
case in the CALL_EXPR write_expression handling, so fn is
then an identifier.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Hmm, I'm a bit uncomfortable exposing builtins in mangling; relatedly, we reject mangling TRAIT_TYPE. But OK.

Jason

Reply via email to