On Mon, Nov 17, 2025 at 07:39:58PM +0100, Jakub Jelinek wrote:
> On Mon, Nov 17, 2025 at 09:39:13AM -0500, Marek Polacek wrote:
> > > --- gcc/cp/parser.cc.jj   2025-11-15 16:03:45.587512374 +0100
> > > +++ gcc/cp/parser.cc      2025-11-17 10:21:57.667975827 +0100
> > > @@ -18779,9 +18779,14 @@ cp_parser_conversion_type_id (cp_parser*
> > >     error ("invalid use of %<auto%> in conversion operator");
> > >     return error_mark_node;
> > >   }
> > > -      else if (template_parm_scope_p ())
> > > - warning (0, "use of %<auto%> in member template "
> > > -          "conversion operator can never be deduced");
> > > +      else
> > > + {
> > 
> > I suppose auto_diagnostic_group doesn't belong here?  
> 
> I thought about that, but am not sure.
> The two diagnostics are for the same issue, sure, but sometimes it
> will be only one of those, sometimes the other one, sometimes both,
> sometimes none.
> 
> Could be also
>   if (!pedwarn (...)
>       && template_parm_scope_p ())
>    warning (0, ...);
> i.e. only emit the warning if pedwarn was silent.

Yeah, then we would definitely not need an auto_diagnostic_group.  The
warning() here could be a nice inform() note, though.  Anyway, I don't
want to complicate things here, what you have looks good (without
an auto_diagnostic_group), thanks.

> > > +   pedwarn (input_location, OPT_Wpedantic,
> > > +            "invalid use of %<auto%> in conversion operator");
> > > +   if (template_parm_scope_p ())
> > > +     warning (0, "use of %<auto%> in member template "
> > > +                 "conversion operator can never be deduced");

Marek

Reply via email to