On Mon, 2025-02-17 at 12:42 -0500, James K. Lowden wrote:
> On Sat, 15 Feb 2025 23:37:20 -0500
> David Malcolm <dmalc...@redhat.com> wrote:
> 
> > +  rich_location richloc (line_table, token_location);
> > +  bool ret = global_dc->diagnostic_impl (&richloc, nullptr,
> > option_id,
> > +                                         gmsgid, &ap, DK_ERROR);
> > +  va_end (ap);
> > +  global_dc->end_group();
> > +}
> > 
> > For errors, just pass 0 as the diagnostic_option_id.  Same for the
> > various DK_SORRY and DK_FATAL.
> 
> OK, but is this a style thing?  That's effectively what happens,
> using a name.  
> 
> option_id is a file-scope static constant, initialized to 0.  Instead
> of passing an integer that the compiler uses to construct a temporary
> diagnostic_option_id, we pass an already-constructed
> diagnostic_option_id by value.  
> 
> (Maybe zero_option_id would be a better name?)

Ah - yes, now I see what you mean.  I like that name.

Can it be "const"?

> 
> > +bool
> > +yywarn( const char gmsgid[], ... ) {
> > +  verify_format(gmsgid);
> > +  auto_diagnostic_group d;
> > +  va_list ap;
> > +  va_start (ap, gmsgid);
> > +  auto ret = emit_diagnostic_valist( DK_WARNING, token_location,
> > +                                     option_id, gmsgid, &ap );
> > +  va_end (ap);
> > +  return ret;
> > +}
> > 
> > For warnings, ideally this should take a diagnostic_option_id
> > controlling the warning as the initial parameter, rather than have
> > a
> > global variable for this.  
> 
> Yes, absolutely.  That's on the to do list.  I wanted to get a set of
> patches submitted for consideration, and drew the line ahead of that
> item.  
> 
> > Is this something that yacc is imposing on you?
> 
> Not at all.  I need to go into gcc/cobol/lang.opt and enumerate the
> warnings.  Then I need to pass the warning ID into yywarn (which will
> be renamed warn_msg() because the "yy" prefix is properly reserved
> for yacc).  
> 
> As we say, just a small matter of programming.  :-) 

Indeed.  It sounds like this is moving in the right direction, and FWIW
I don't have a problem with it going into trunk in its current state.

Dave

Reply via email to