This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: Named warnings
- From: Bruce Korb <bkorb at veritas dot com>
- To: DJ Delorie <dj at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Fri, 24 Jan 2003 12:54:18 -0800
- Subject: Re: RFC: Named warnings
- Reply-to: bkorb at veritas dot com
> > Present code:
> >
> > /* Issue a warning if this is an ISO C 99 program or if -Wreturn-type
> > and this is a function, or if -Wimplicit; prefer the former
> > warning since it is more explicit. */
> > if ((warn_implicit_int || warn_return_type || flag_isoc99)
> > && funcdef_flag)
> > warn_about_return_type = 1;
> > else if (warn_implicit_int || flag_isoc99)
> > pedwarn_c99 ("type defaults to `int' in declaration of `%s'",
> > name);
>
> I would think something like this:
>
> warn ("functions.retval.type-defaults", "...");
>
> And somewhere *else* we figure out whether this warning should be
> enabled or not based on the c89/c99/pedantic/-W options.
Wouldn't this be simpler?
/*=warn type-defaults-to-int
* fmt: "type defaults to `int' in declaration of `%s'"
* group: pedantic isoc99 return-type funcdef
* disabled:
* doc: No return type was specified for your procedure.
* You should type it explicitly to "int", if it returns an int,
* or set it to void if no value is returned.
=*/
WARN_TYPE_DEFAULTS_TO_INT( name );
And, elsewhere you have - generated - :
#define WARN_ID_TYPE_DEFAULTS_TO_INT <<some-number>>
#define WARN_TYPE_DEFAULTS_TO_INT( a1 ) \
if (warn_enabled[ WARN_ID_TYPE_DEFAULTS_TO_INT ]) \
warning ("type defaults to `int' in declaration of `%s'", \
(a1) );
and a bit of initialization code that turns on the warnings related
to "pedantic", "isoc99", "return-type" and "funcdef" -- including
the entry for WARN_ID_TYPE_DEFAULTS_TO_INT