On Thu, 2020-05-21 at 00:48 +0200, Mark Wielaard wrote:
> Hi,
> 
> On Mon, May 18, 2020 at 07:30:58PM -0400, Marek Polacek wrote:
> > > +  /* Returns a replacement function as text if it
> > > exists.  Currently
> > > +     only "exit" has a signal-safe replacement "_exit", which
> > > does
> > > +     slightly less, but can be used in a signal handler.  */
> > > +  const char *
> > > +  get_replacement_fn ()
> > > +  {
> > > +    gcc_assert (m_unsafe_fndecl && DECL_P (m_unsafe_fndecl));
> > > +
> > > +    if (strcmp ("exit",
> > > +         IDENTIFIER_POINTER (DECL_NAME (m_unsafe_fndecl))) == 0)
> > 
> > Instead of strcmp, you should be able to use id_equal here, making
> > this a bit
> > simpler.
> 
> That does make it a little easier to read.
> How about the attached?
> 
> Thanks,
> 
> Mark

> +  exit(1); /* { dg-warning "call to 'exit' from within signal handler" } */
> +  /* { dg-message "note: '_exit' is a possible signal-safe alternative for 
> 'exit'" "" { target *-*-* } 12 } */

A couple of nits here:

(a) if two dg diagnostic directives share the same line, it's best to
give them names so that they can be disambiguated in the gcc.sum
output, in case something starts failing for some reason.  So please
replace that "" with e.g. "replacement note" and give the warning a
name (e.g. "warning").

(b) rather than hardcoding the absolute line number as 12 above, it's
more future-proof to use a relative line number .-1

So the above should read something like:

+  exit(1); /* { dg-warning "call to 'exit' from within signal handler" 
"warning" } */
+  /* { dg-message "note: '_exit' is a possible signal-safe alternative for 
'exit'" "replacement note" { target *-*-* } .-1 } */

OK with that change (but please double-check I got the syntax correct!)

Thanks
Dave

Reply via email to