This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: simple fix for a few warning (0).
On 28/01/07, Paolo Bonzini <paolo.bonzini@lu.unisi.ch> wrote:
> else if (!TREE_USED (p) && warn_unused_label)
> {
> if (DECL_INITIAL (p))
> - warning (0, "label %q+D defined but not used", p);
> + warning (OPT_Wunused_label, "label %q+D defined but not used", p);
> else
> - warning (0, "label %q+D declared but not defined", p);
> + warning (OPT_Wunused_label, "label %q+D declared but not defined", p);
You should also remove the "&& warn_unused_label" above.
I think that is a bad practice in general. The advantages of keeping
the warn_* around are 1) it shows that any operation in the block is
done only for emitting the warning, not for anything essential and 2)
if -Wunused-label is disabled, it saves us from calling warning() at
all, which is certainly more expensive than checking
warn_unused_label.
You should take into account that the goal of using warning (OPT_W*, )
instead of warning (0,) is to enable printing the option that
generated the warning and to be able to reclassificate the warning as
something else (warning, error, disable), through, for example, a
#pragma directive, even if warn_unused_label is true.
Of course, in this particular case perhaps it is not needed, since the
block is small and it doesn't perform many operations. If the
diagnostics maintainer (or whoever may approve this patch) agrees with
you, I will remove it and resubmit.
Cheers,
Manuel.