On Wed, Feb 11, 2026 at 11:54:58AM -0500, Marek Polacek wrote:
> > Though, why not just use %qE and make sure to pass a REFLECT_EXPR and
> > ensure it is printed in human readable form (partly kind like
> > display_string_of, but e.g. with ^^ at the start).
>
> Would it be better if tree_category returned e.g.
>
> return G_(" (type)");
>
> and is then used at the end of the error message like this:
>
> error_at (loc, "expected a reflection of ... "
> "instead of %qE" "%s", t, tree_category (t));
>
> or is it still bad wrt translation? %s because I don't want to
> quote the category. This would produce:
>
> error: expected a reflection of a function template instead of 'x' (variable)
Maybe.
Yet another option would be a pair of diagnostic messages:
auto_diagnostic_group d;
error_at (loc, "expected a reflection of ... ");
inform (loc, "while %qE is a variable", t);
where the inform could be done in a helper function which various
error_at callers would call to explain stuff.
Jakub