On Mon, Jul 13, 2026 at 11:45:00AM -0400, Jason Merrill wrote:
> On 7/13/26 3:36 AM, Vladislav Semykin wrote:
> > Per recent Coverity feedback on PR126207, I'd suggest a small
> > refactor: add a nonnull out-parameter to typeid_evaluated_p. This:
> >
> > 1. avoids calling resolves_to_fixed_type_p twice (once inside
> > typeid_evaluated_p, once again in build_typeid), and
> > 2. removes the unchecked return value Coverity flagged in the
> > second call.
> >
> > @@ -345,7 +345,7 @@ typeid_ok_p (void)
> > evaluated per ([expr.typeid]/4). */
> > bool
> > -typeid_evaluated_p (tree exp)
> > +typeid_evaluated_p (tree exp, int *nonnull)
> > {
> > if (exp == error_mark_node)
> > return false;
>
> > @@ -356,9 +356,12 @@ typeid_evaluated_p (tree exp)
> > t = TREE_TYPE (t);
> > if (TREE_CODE (t) != RECORD_TYPE && TREE_CODE (t) != UNION_TYPE)
> > return false;
> > - int nonnull = 0;
> > + int nn = 0;
> > + bool fixed = resolves_to_fixed_type_p (exp, &nn);
> > + if (nonnull)
> > + *nonnull = nn;
>
> We should be able to just pass down the new nonnull parameter and drop the
> local variable.
The patch should also use nullptr instead of NULL and document the new
parameter.
Marek