Re: [PATCH] fix more -Wformat-diag issues

2019-06-07 Thread Martin Sebor

On 6/7/19 6:57 AM, Christophe Lyon wrote:

On Wed, 5 Jun 2019 at 20:33, Martin Sebor  wrote:


On 5/31/19 12:20 PM, Jeff Law wrote:

On 5/31/19 9:56 AM, Martin Sebor wrote:

On 5/30/19 5:49 PM, Jeff Law wrote:

So in several places there's a comment which indicates that debugging
dumps and the like do not follow conventions.  Presumably you've tried
to keep a narrow scope on the diagnostic push/pops.  I'm also concerned
that the comments you mention that we trigger an ICE.

So while I'll ack this patch, I would like to know more about the ICE
that's triggered in the checker and what the plans are for fixing it.


Sorry, I didn't word the comment (copied below) very clearly.
What I meant to say is that the calls to error() in these files
that don't follow the convention are ultimately followed by
an ICE triggered either by an assert (as in cfgloop.c) or a call
to internal_error (cgraph.h).  The diagnostics themselves don't
cause an ICE.

OK.  Thanks for the clarification.



In a comment on one of the i18n bugs raised for these strings
Richard suggests these error calls should probably replaced by
direct calls to the pretty printer.  That would let us avoid
suppressing the warnings and also presumably make it clear to
translators the format strings aren't meant to be translated.
It seemed like too big of a change for this patch so I simply
suppressed the warnings but I agree it's worth considering at
some point.

Agreed.



I'll adjust the comment before I check in the patch (I'm hoping
to commit it at the same time as the checker itself once it's
approved).

Your call on when to commit :-)


I just committed it in r271971 with a few minor tweaks.  As before
I expect some minor fallout in the test suite, and more fixes to
follow once the checker itself is approved and committed.



Hi,

I suspect you've already noticed that
FAIL: gcc.dg/format/gcc_diag-11.c

on arm, aarch64 and x86 according to gcc-testresults.


Yes, it fails everywhere because the warning patch itself hasn't
been approved yet.  I committed the test by accident along with
the cleanup, and I disabled it in r271975.

Martin



Christophe



Martin




Re: [PATCH] fix more -Wformat-diag issues

2019-06-07 Thread Christophe Lyon
On Wed, 5 Jun 2019 at 20:33, Martin Sebor  wrote:
>
> On 5/31/19 12:20 PM, Jeff Law wrote:
> > On 5/31/19 9:56 AM, Martin Sebor wrote:
> >> On 5/30/19 5:49 PM, Jeff Law wrote:
> >>> So in several places there's a comment which indicates that debugging
> >>> dumps and the like do not follow conventions.  Presumably you've tried
> >>> to keep a narrow scope on the diagnostic push/pops.  I'm also concerned
> >>> that the comments you mention that we trigger an ICE.
> >>>
> >>> So while I'll ack this patch, I would like to know more about the ICE
> >>> that's triggered in the checker and what the plans are for fixing it.
> >>
> >> Sorry, I didn't word the comment (copied below) very clearly.
> >> What I meant to say is that the calls to error() in these files
> >> that don't follow the convention are ultimately followed by
> >> an ICE triggered either by an assert (as in cfgloop.c) or a call
> >> to internal_error (cgraph.h).  The diagnostics themselves don't
> >> cause an ICE.
> > OK.  Thanks for the clarification.
> >
> >>
> >> In a comment on one of the i18n bugs raised for these strings
> >> Richard suggests these error calls should probably replaced by
> >> direct calls to the pretty printer.  That would let us avoid
> >> suppressing the warnings and also presumably make it clear to
> >> translators the format strings aren't meant to be translated.
> >> It seemed like too big of a change for this patch so I simply
> >> suppressed the warnings but I agree it's worth considering at
> >> some point.
> > Agreed.
> >
> >>
> >> I'll adjust the comment before I check in the patch (I'm hoping
> >> to commit it at the same time as the checker itself once it's
> >> approved).
> > Your call on when to commit :-)
>
> I just committed it in r271971 with a few minor tweaks.  As before
> I expect some minor fallout in the test suite, and more fixes to
> follow once the checker itself is approved and committed.
>

Hi,

I suspect you've already noticed that
FAIL: gcc.dg/format/gcc_diag-11.c

on arm, aarch64 and x86 according to gcc-testresults.

Christophe


> Martin


Re: [PATCH] fix more -Wformat-diag issues

2019-06-06 Thread Martin Sebor

On 6/6/19 9:42 AM, Jakub Jelinek wrote:

On Thu, Jun 06, 2019 at 08:45:56AM -0600, Martin Sebor wrote:

Changes for the same change shouldn't be separated by empty newlines in the
ChangeLog.  Furthermore, you've managed to commit only the first part (until
varasm.c) and not the rest.


I actually managed to do that on purpose.  I just didn't "manage"
to also update the ever important ChangeLog.  There are probably
other mistakes in it.


The coding conventions says not to, so have you violated that on purpose?


Are you for real?  Yes, I added a blank line on purpose.


https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html#Style-of-Change-Logs
"Separate unrelated change log entries with blank lines.
Don’t put blank lines between individual changes of an entry."


It's pretty pathetic that the only thing you choose to say in
response to my change to better align GCC code with the coding
conventions is to chastise me for trying to make the ChangeLog
entry more readable by adding a blank line to it.


I don't see any changes in that patch as unrelated, after all, if they were
unrelated, they ought to be committed separately.


Thanks for the lecture.


Re: [PATCH] fix more -Wformat-diag issues

2019-06-06 Thread Jakub Jelinek
On Thu, Jun 06, 2019 at 08:45:56AM -0600, Martin Sebor wrote:
> > Changes for the same change shouldn't be separated by empty newlines in the
> > ChangeLog.  Furthermore, you've managed to commit only the first part (until
> > varasm.c) and not the rest.
> 
> I actually managed to do that on purpose.  I just didn't "manage"
> to also update the ever important ChangeLog.  There are probably
> other mistakes in it.

The coding conventions says not to, so have you violated that on purpose?
https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html#Style-of-Change-Logs
"Separate unrelated change log entries with blank lines.
Don’t put blank lines between individual changes of an entry."

I don't see any changes in that patch as unrelated, after all, if they were
unrelated, they ought to be committed separately.

Jakub


Re: [PATCH] fix more -Wformat-diag issues

2019-06-06 Thread Martin Sebor

On 6/6/19 3:39 AM, Jakub Jelinek wrote:

On Wed, May 22, 2019 at 10:34:00AM -0600, Martin Sebor wrote:

gcc/ChangeLog:

* config/i386/i386-features.c (ix86_get_function_versions_dispatcher):
Adjust quoting and hyphenation.
* convert.c (convert_to_real_1): Same.
* gcc.c (driver_wrong_lang_callback): Same.
(driver::handle_unrecognized_options): Same.
* gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same.
* opts-common.c (cmdline_handle_error): Same.
(read_cmdline_option): Same.
* opts-global.c (complain_wrong_lang): Same.
(print_ignored_options): Same.
(handle_common_deferred_options): Same.
* pretty-print.h: Same.
* print-rtl.c (debug_bb_n_slim): Same.
* sched-rgn.c (make_pass_sched_fusion): Same.
* tree-cfg.c (verify_gimple_assign_unary): Same.
(verify_gimple_label): Same.
* tree-ssa-operands.c (verify_ssa_operands): Same.
* varasm.c (do_assemble_alias): Same.
(assemble_alias): Same.

* diagnostic-core.h (GCC_DIAG_STYLE): Adjust.
 (GCC_DIAG_RAW_STYLE): New macro.

* cfghooks.c: Disable -Wformat-diags.
* cfgloop.c: Same.
* cfgrtl.c: Same.
* cgraph.c: Same.
* diagnostic-show-locus.c: Same.
* diagnostic.c: Same.
* gimple-pretty-print.c: Same.
* graph.c: Same.
* symtab.c: Same.
* tree-eh.c Same.
* tree-pretty-print.c: Same.
* tree-ssa.c: Same.

* configure: Regenerate.
* configure.ac (ACX_PROG_CXX_WARNING_OPTS): Add -Wno-error=format-diag.
 (ACX_PROG_CC_WARNING_OPTS): Same.


Changes for the same change shouldn't be separated by empty newlines in the
ChangeLog.  Furthermore, you've managed to commit only the first part (until
varasm.c) and not the rest.


I actually managed to do that on purpose.  I just didn't "manage"
to also update the ever important ChangeLog.  There are probably
other mistakes in it.




diff --git a/gcc/configure b/gcc/configure
index 4a3d5eefcb8..c9062cca9d6 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -6797,7 +6797,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
  
  c_loose_warn=

  save_CFLAGS="$CFLAGS"
-for real_option in -Wstrict-prototypes -Wmissing-prototypes; do
+for real_option in -Wstrict-prototypes 
-Wmissing-prototypes-Wno-error=format-diag; do
# Do the check with the no- prefix removed since gcc silently
# accepts any -Wno-* option on purpose
case $real_option in


The above was probably regenerated before you've added a space:


Yes.




diff --git a/gcc/configure.ac b/gcc/configure.ac
index 35982fdc9ed..cbc0c25fa2b 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -483,10 +483,11 @@ AS_IF([test $enable_build_format_warnings = no],
[wf_opt=-Wno-format],[wf_opt=])
  ACX_PROG_CXX_WARNING_OPTS(
m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
-  [-Wcast-qual $wf_opt])), [loose_warn])
+  [-Wcast-qual -Wno-error=format-diag $wf_opt])),
+  [loose_warn])
  ACX_PROG_CC_WARNING_OPTS(
-   m4_quote(m4_do([-Wstrict-prototypes -Wmissing-prototypes])),
-   [c_loose_warn])
+   m4_quote(m4_do([-Wstrict-prototypes -Wmissing-prototypes ],


 ^--HERE
I've committed following to fix that up as obvious:


Thank you.

Martin



2019-06-06  Jakub Jelinek  

* configure: Regenerate.

--- gcc/configure   (revision 271993)
+++ gcc/configure   (revision 271994)
@@ -6797,7 +6797,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
  
  c_loose_warn=

  save_CFLAGS="$CFLAGS"
-for real_option in -Wstrict-prototypes 
-Wmissing-prototypes-Wno-error=format-diag; do
+for real_option in -Wstrict-prototypes -Wmissing-prototypes 
-Wno-error=format-diag; do
# Do the check with the no- prefix removed since gcc silently
# accepts any -Wno-* option on purpose
case $real_option in


Jakub





Re: [PATCH] fix more -Wformat-diag issues

2019-06-06 Thread Jakub Jelinek
On Wed, May 22, 2019 at 10:34:00AM -0600, Martin Sebor wrote:
> gcc/ChangeLog:
> 
>   * config/i386/i386-features.c (ix86_get_function_versions_dispatcher):
>   Adjust quoting and hyphenation.
>   * convert.c (convert_to_real_1): Same.
>   * gcc.c (driver_wrong_lang_callback): Same.
>   (driver::handle_unrecognized_options): Same.
>   * gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same.
>   * opts-common.c (cmdline_handle_error): Same.
>   (read_cmdline_option): Same.
>   * opts-global.c (complain_wrong_lang): Same.
>   (print_ignored_options): Same.
>   (handle_common_deferred_options): Same.
>   * pretty-print.h: Same.
>   * print-rtl.c (debug_bb_n_slim): Same.
>   * sched-rgn.c (make_pass_sched_fusion): Same.
>   * tree-cfg.c (verify_gimple_assign_unary): Same.
>   (verify_gimple_label): Same.
>   * tree-ssa-operands.c (verify_ssa_operands): Same.
>   * varasm.c (do_assemble_alias): Same.
>   (assemble_alias): Same.
> 
>   * diagnostic-core.h (GCC_DIAG_STYLE): Adjust.
>(GCC_DIAG_RAW_STYLE): New macro.
> 
>   * cfghooks.c: Disable -Wformat-diags.
>   * cfgloop.c: Same.
>   * cfgrtl.c: Same.
>   * cgraph.c: Same.
>   * diagnostic-show-locus.c: Same.
>   * diagnostic.c: Same.
>   * gimple-pretty-print.c: Same.
>   * graph.c: Same.
>   * symtab.c: Same.
>   * tree-eh.c Same.
>   * tree-pretty-print.c: Same.
>   * tree-ssa.c: Same.
> 
>   * configure: Regenerate.
>   * configure.ac (ACX_PROG_CXX_WARNING_OPTS): Add -Wno-error=format-diag.
>(ACX_PROG_CC_WARNING_OPTS): Same.

Changes for the same change shouldn't be separated by empty newlines in the
ChangeLog.  Furthermore, you've managed to commit only the first part (until
varasm.c) and not the rest.

> diff --git a/gcc/configure b/gcc/configure
> index 4a3d5eefcb8..c9062cca9d6 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -6797,7 +6797,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
>  
>  c_loose_warn=
>  save_CFLAGS="$CFLAGS"
> -for real_option in -Wstrict-prototypes -Wmissing-prototypes; do
> +for real_option in -Wstrict-prototypes 
> -Wmissing-prototypes-Wno-error=format-diag; do
># Do the check with the no- prefix removed since gcc silently
># accepts any -Wno-* option on purpose
>case $real_option in

The above was probably regenerated before you've added a space:

> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 35982fdc9ed..cbc0c25fa2b 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -483,10 +483,11 @@ AS_IF([test $enable_build_format_warnings = no],
>[wf_opt=-Wno-format],[wf_opt=])
>  ACX_PROG_CXX_WARNING_OPTS(
>   m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
> -[-Wcast-qual $wf_opt])), [loose_warn])
> +[-Wcast-qual -Wno-error=format-diag $wf_opt])),
> +[loose_warn])
>  ACX_PROG_CC_WARNING_OPTS(
> - m4_quote(m4_do([-Wstrict-prototypes -Wmissing-prototypes])),
> - [c_loose_warn])
> + m4_quote(m4_do([-Wstrict-prototypes -Wmissing-prototypes ],

^--HERE
I've committed following to fix that up as obvious:

2019-06-06  Jakub Jelinek  

* configure: Regenerate.

--- gcc/configure   (revision 271993)
+++ gcc/configure   (revision 271994)
@@ -6797,7 +6797,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 c_loose_warn=
 save_CFLAGS="$CFLAGS"
-for real_option in -Wstrict-prototypes 
-Wmissing-prototypes-Wno-error=format-diag; do
+for real_option in -Wstrict-prototypes -Wmissing-prototypes 
-Wno-error=format-diag; do
   # Do the check with the no- prefix removed since gcc silently
   # accepts any -Wno-* option on purpose
   case $real_option in


Jakub


Re: [PATCH] fix more -Wformat-diag issues

2019-06-05 Thread Martin Sebor

On 5/31/19 12:20 PM, Jeff Law wrote:

On 5/31/19 9:56 AM, Martin Sebor wrote:

On 5/30/19 5:49 PM, Jeff Law wrote:

So in several places there's a comment which indicates that debugging
dumps and the like do not follow conventions.  Presumably you've tried
to keep a narrow scope on the diagnostic push/pops.  I'm also concerned
that the comments you mention that we trigger an ICE.

So while I'll ack this patch, I would like to know more about the ICE
that's triggered in the checker and what the plans are for fixing it.


Sorry, I didn't word the comment (copied below) very clearly.
What I meant to say is that the calls to error() in these files
that don't follow the convention are ultimately followed by
an ICE triggered either by an assert (as in cfgloop.c) or a call
to internal_error (cgraph.h).  The diagnostics themselves don't
cause an ICE.

OK.  Thanks for the clarification.



In a comment on one of the i18n bugs raised for these strings
Richard suggests these error calls should probably replaced by
direct calls to the pretty printer.  That would let us avoid
suppressing the warnings and also presumably make it clear to
translators the format strings aren't meant to be translated.
It seemed like too big of a change for this patch so I simply
suppressed the warnings but I agree it's worth considering at
some point.

Agreed.



I'll adjust the comment before I check in the patch (I'm hoping
to commit it at the same time as the checker itself once it's
approved).

Your call on when to commit :-)


I just committed it in r271971 with a few minor tweaks.  As before
I expect some minor fallout in the test suite, and more fixes to
follow once the checker itself is approved and committed.

Martin


Re: [PATCH] fix more -Wformat-diag issues

2019-05-31 Thread Jeff Law
On 5/31/19 9:56 AM, Martin Sebor wrote:
> On 5/30/19 5:49 PM, Jeff Law wrote:
>> So in several places there's a comment which indicates that debugging
>> dumps and the like do not follow conventions.  Presumably you've tried
>> to keep a narrow scope on the diagnostic push/pops.  I'm also concerned
>> that the comments you mention that we trigger an ICE.
>>
>> So while I'll ack this patch, I would like to know more about the ICE
>> that's triggered in the checker and what the plans are for fixing it.
> 
> Sorry, I didn't word the comment (copied below) very clearly.
> What I meant to say is that the calls to error() in these files
> that don't follow the convention are ultimately followed by
> an ICE triggered either by an assert (as in cfgloop.c) or a call
> to internal_error (cgraph.h).  The diagnostics themselves don't
> cause an ICE.
OK.  Thanks for the clarification.

> 
> In a comment on one of the i18n bugs raised for these strings
> Richard suggests these error calls should probably replaced by
> direct calls to the pretty printer.  That would let us avoid
> suppressing the warnings and also presumably make it clear to
> translators the format strings aren't meant to be translated.
> It seemed like too big of a change for this patch so I simply
> suppressed the warnings but I agree it's worth considering at
> some point.
Agreed.

> 
> I'll adjust the comment before I check in the patch (I'm hoping
> to commit it at the same time as the checker itself once it's
> approved).
Your call on when to commit :-)

Jeff



Re: [PATCH] fix more -Wformat-diag issues

2019-05-31 Thread Martin Sebor

On 5/30/19 5:49 PM, Jeff Law wrote:

On 5/22/19 10:34 AM, Martin Sebor wrote:

Incorporating the feedback I got on the -Wformat-diag checker
provided an opportunity to tighten up existing and implement
a small number of few additional rules based on GCC Coding
Conventions (https://gcc.gnu.org/codingconventions.html).
The checker now also warns for incorrect uses of the following:

  *  bitfield (rather than bit-field)
  *  builtin (rather than built-in)
  *  command line (rather than command-line)
  *  enumeral (rather than enumerated)
  *  floating point (rather than floating-point)
  *  non-zero (rather than nonzero)

In addition, it has become better at finding unquoted qualifiers
(like const in const-qualified or "const %qT" rather than %"), and detects some additional abbreviations (e.g., "stmt"
instead of "statement").

These improvements exposed a number of additional issues in our
sources that the attached patch corrects.

As before, I have tested the patch on x86_64-linux and adjusted
the fallout in the test suite.  More cleanup will likely be needed
on other targets but based on the prior changes I don't expect it
to be extensive.

I will post the patch with the checker implementation separately.

Martin

PS As discussed in the thread below, some of the instances of
added hyphenation in "floating-point" aren't strictly necessary
and the  wording might need to be tweaked a bit to make it so:
   https://gcc.gnu.org/ml/gcc/2019-05/msg00168.html
I'll handle it in a subsequent commit if it's viewed important.

gcc-wformat-diag.diff

gcc/c/ChangeLog:

* c-decl.c (start_decl): Adjust quoting and hyphenation
in diagnostics.
(finish_decl): Same.
(finish_enum): Same.
(start_function): Same.
(declspecs_add_type): Same.
* c-parser.c (warn_for_abs): Same.
* c-typeck.c (build_binary_op): Same.

gcc/c-family/ChangeLog:

* c-attribs.c (handle_mode_attribute): Adjust quoting and hyphenation.
(handle_alias_ifunc_attribute): Same.
(handle_copy_attribute): Same.
(handle_weakref_attribute): Same.
(handle_nonnull_attribute): Same.
* c-warn.c (warn_for_sign_compare): Same.
(warn_for_restrict): Same.
* c.opt: Same.

* c-common.h (GCC_DIAG_STYLE): Adjust.
 (GCC_DIAG_RAW_STYLE): New macro.

gcc/cp/ChangeLog:

* call.c (build_conditional_expr_1): Adjust quoting and hyphenation.
(convert_like_real): Same.
(convert_arg_to_ellipsis): Same.
* constexpr.c (diag_array_subscript): Same.
* constraint.cc (diagnose_trait_expression): Same.
* cvt.c (ocp_convert): Same.
* decl.c (start_decl): Same.
(check_for_uninitialized_const_var): Same.
(grokfndecl): Same.
(check_special_function_return_type): Same.
(finish_enum_value_list): Same.
(start_preparsed_function): Same.
* parser.c (cp_parser_decl_specifier_seq): Same.
* typeck.c (cp_build_binary_op): Same.
(build_static_cast_1): Same.

* cp-tree.h (GCC_DIAG_STYLE): Adjust.
 (GCC_DIAG_RAW_STYLE): New macro.

gcc/lto/ChangeLog:

* lto-common.c (lto_file_finalize): Adjust quoting and hyphenation.

gcc/objc/ChangeLog:

* objc-act.c (objc_build_setter_call): Adjust quoting and hyphenation.
* objc-encoding.c (encode_gnu_bitfield): Same.

gcc/ChangeLog:

* config/i386/i386-features.c (ix86_get_function_versions_dispatcher):
Adjust quoting and hyphenation.
* convert.c (convert_to_real_1): Same.
* gcc.c (driver_wrong_lang_callback): Same.
(driver::handle_unrecognized_options): Same.
* gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same.
* opts-common.c (cmdline_handle_error): Same.
(read_cmdline_option): Same.
* opts-global.c (complain_wrong_lang): Same.
(print_ignored_options): Same.
(handle_common_deferred_options): Same.
* pretty-print.h: Same.
* print-rtl.c (debug_bb_n_slim): Same.
* sched-rgn.c (make_pass_sched_fusion): Same.
* tree-cfg.c (verify_gimple_assign_unary): Same.
(verify_gimple_label): Same.
* tree-ssa-operands.c (verify_ssa_operands): Same.
* varasm.c (do_assemble_alias): Same.
(assemble_alias): Same.

* diagnostic-core.h (GCC_DIAG_STYLE): Adjust.
 (GCC_DIAG_RAW_STYLE): New macro.

* cfghooks.c: Disable -Wformat-diags.
* cfgloop.c: Same.
* cfgrtl.c: Same.
* cgraph.c: Same.
* diagnostic-show-locus.c: Same.
* diagnostic.c: Same.
* gimple-pretty-print.c: Same.
* graph.c: Same.
* symtab.c: Same.
* tree-eh.c Same.
* tree-pretty-print.c: Same.
* tree-ssa.c: Same.

* configure: Regenerate.
* configure.ac (ACX_PROG_CXX_WARNING_OPTS): Add -Wno-error=format-diag.
 (ACX_PROG_CC_WARNING_OPTS): Same.

Re: [PATCH] fix more -Wformat-diag issues

2019-05-30 Thread Jeff Law
On 5/22/19 10:34 AM, Martin Sebor wrote:
> Incorporating the feedback I got on the -Wformat-diag checker
> provided an opportunity to tighten up existing and implement
> a small number of few additional rules based on GCC Coding
> Conventions (https://gcc.gnu.org/codingconventions.html).
> The checker now also warns for incorrect uses of the following:
> 
>  *  bitfield (rather than bit-field)
>  *  builtin (rather than built-in)
>  *  command line (rather than command-line)
>  *  enumeral (rather than enumerated)
>  *  floating point (rather than floating-point)
>  *  non-zero (rather than nonzero)
> 
> In addition, it has become better at finding unquoted qualifiers
> (like const in const-qualified or "const %qT" rather than % %T%>"), and detects some additional abbreviations (e.g., "stmt"
> instead of "statement").
> 
> These improvements exposed a number of additional issues in our
> sources that the attached patch corrects.
> 
> As before, I have tested the patch on x86_64-linux and adjusted
> the fallout in the test suite.  More cleanup will likely be needed
> on other targets but based on the prior changes I don't expect it
> to be extensive.
> 
> I will post the patch with the checker implementation separately.
> 
> Martin
> 
> PS As discussed in the thread below, some of the instances of
> added hyphenation in "floating-point" aren't strictly necessary
> and the  wording might need to be tweaked a bit to make it so:
>   https://gcc.gnu.org/ml/gcc/2019-05/msg00168.html
> I'll handle it in a subsequent commit if it's viewed important.
> 
> gcc-wformat-diag.diff
> 
> gcc/c/ChangeLog:
> 
>   * c-decl.c (start_decl): Adjust quoting and hyphenation
>   in diagnostics.
>   (finish_decl): Same.
>   (finish_enum): Same.
>   (start_function): Same.
>   (declspecs_add_type): Same.
>   * c-parser.c (warn_for_abs): Same.
>   * c-typeck.c (build_binary_op): Same.
> 
> gcc/c-family/ChangeLog:
> 
>   * c-attribs.c (handle_mode_attribute): Adjust quoting and hyphenation.
>   (handle_alias_ifunc_attribute): Same.
>   (handle_copy_attribute): Same.
>   (handle_weakref_attribute): Same.
>   (handle_nonnull_attribute): Same.
>   * c-warn.c (warn_for_sign_compare): Same.
>   (warn_for_restrict): Same.
>   * c.opt: Same.
> 
>   * c-common.h (GCC_DIAG_STYLE): Adjust.
>(GCC_DIAG_RAW_STYLE): New macro.
> 
> gcc/cp/ChangeLog:
> 
>   * call.c (build_conditional_expr_1): Adjust quoting and hyphenation.
>   (convert_like_real): Same.
>   (convert_arg_to_ellipsis): Same.
>   * constexpr.c (diag_array_subscript): Same.
>   * constraint.cc (diagnose_trait_expression): Same.
>   * cvt.c (ocp_convert): Same.
>   * decl.c (start_decl): Same.
>   (check_for_uninitialized_const_var): Same.
>   (grokfndecl): Same.
>   (check_special_function_return_type): Same.
>   (finish_enum_value_list): Same.
>   (start_preparsed_function): Same.
>   * parser.c (cp_parser_decl_specifier_seq): Same.
>   * typeck.c (cp_build_binary_op): Same.
>   (build_static_cast_1): Same.
> 
>   * cp-tree.h (GCC_DIAG_STYLE): Adjust.
>(GCC_DIAG_RAW_STYLE): New macro.
> 
> gcc/lto/ChangeLog:
> 
>   * lto-common.c (lto_file_finalize): Adjust quoting and hyphenation.
> 
> gcc/objc/ChangeLog:
> 
>   * objc-act.c (objc_build_setter_call): Adjust quoting and hyphenation.
>   * objc-encoding.c (encode_gnu_bitfield): Same.
> 
> gcc/ChangeLog:
> 
>   * config/i386/i386-features.c (ix86_get_function_versions_dispatcher):
>   Adjust quoting and hyphenation.
>   * convert.c (convert_to_real_1): Same.
>   * gcc.c (driver_wrong_lang_callback): Same.
>   (driver::handle_unrecognized_options): Same.
>   * gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same.
>   * opts-common.c (cmdline_handle_error): Same.
>   (read_cmdline_option): Same.
>   * opts-global.c (complain_wrong_lang): Same.
>   (print_ignored_options): Same.
>   (handle_common_deferred_options): Same.
>   * pretty-print.h: Same.
>   * print-rtl.c (debug_bb_n_slim): Same.
>   * sched-rgn.c (make_pass_sched_fusion): Same.
>   * tree-cfg.c (verify_gimple_assign_unary): Same.
>   (verify_gimple_label): Same.
>   * tree-ssa-operands.c (verify_ssa_operands): Same.
>   * varasm.c (do_assemble_alias): Same.
>   (assemble_alias): Same.
> 
>   * diagnostic-core.h (GCC_DIAG_STYLE): Adjust.
>(GCC_DIAG_RAW_STYLE): New macro.
> 
>   * cfghooks.c: Disable -Wformat-diags.
>   * cfgloop.c: Same.
>   * cfgrtl.c: Same.
>   * cgraph.c: Same.
>   * diagnostic-show-locus.c: Same.
>   * diagnostic.c: Same.
>   * gimple-pretty-print.c: Same.
>   * graph.c: Same.
>   * symtab.c: Same.
>   * tree-eh.c Same.
>   * tree-pretty-print.c: Same.
>   * tree-ssa.c: Same.
> 
>   * configure: Regenerate.
>   * configure.ac 

[PATCH] fix more -Wformat-diag issues

2019-05-22 Thread Martin Sebor

Incorporating the feedback I got on the -Wformat-diag checker
provided an opportunity to tighten up existing and implement
a small number of few additional rules based on GCC Coding
Conventions (https://gcc.gnu.org/codingconventions.html).
The checker now also warns for incorrect uses of the following:

 *  bitfield (rather than bit-field)
 *  builtin (rather than built-in)
 *  command line (rather than command-line)
 *  enumeral (rather than enumerated)
 *  floating point (rather than floating-point)
 *  non-zero (rather than nonzero)

In addition, it has become better at finding unquoted qualifiers
(like const in const-qualified or "const %qT" rather than %"), and detects some additional abbreviations (e.g., "stmt"
instead of "statement").

These improvements exposed a number of additional issues in our
sources that the attached patch corrects.

As before, I have tested the patch on x86_64-linux and adjusted
the fallout in the test suite.  More cleanup will likely be needed
on other targets but based on the prior changes I don't expect it
to be extensive.

I will post the patch with the checker implementation separately.

Martin

PS As discussed in the thread below, some of the instances of
added hyphenation in "floating-point" aren't strictly necessary
and the  wording might need to be tweaked a bit to make it so:
  https://gcc.gnu.org/ml/gcc/2019-05/msg00168.html
I'll handle it in a subsequent commit if it's viewed important.
gcc/c/ChangeLog:

	* c-decl.c (start_decl): Adjust quoting and hyphenation
	in diagnostics.
	(finish_decl): Same.
	(finish_enum): Same.
	(start_function): Same.
	(declspecs_add_type): Same.
	* c-parser.c (warn_for_abs): Same.
	* c-typeck.c (build_binary_op): Same.

gcc/c-family/ChangeLog:

	* c-attribs.c (handle_mode_attribute): Adjust quoting and hyphenation.
	(handle_alias_ifunc_attribute): Same.
	(handle_copy_attribute): Same.
	(handle_weakref_attribute): Same.
	(handle_nonnull_attribute): Same.
	* c-warn.c (warn_for_sign_compare): Same.
	(warn_for_restrict): Same.
	* c.opt: Same.

	* c-common.h (GCC_DIAG_STYLE): Adjust.
	 (GCC_DIAG_RAW_STYLE): New macro.

gcc/cp/ChangeLog:

	* call.c (build_conditional_expr_1): Adjust quoting and hyphenation.
	(convert_like_real): Same.
	(convert_arg_to_ellipsis): Same.
	* constexpr.c (diag_array_subscript): Same.
	* constraint.cc (diagnose_trait_expression): Same.
	* cvt.c (ocp_convert): Same.
	* decl.c (start_decl): Same.
	(check_for_uninitialized_const_var): Same.
	(grokfndecl): Same.
	(check_special_function_return_type): Same.
	(finish_enum_value_list): Same.
	(start_preparsed_function): Same.
	* parser.c (cp_parser_decl_specifier_seq): Same.
	* typeck.c (cp_build_binary_op): Same.
	(build_static_cast_1): Same.

	* cp-tree.h (GCC_DIAG_STYLE): Adjust.
	 (GCC_DIAG_RAW_STYLE): New macro.

gcc/lto/ChangeLog:

	* lto-common.c (lto_file_finalize): Adjust quoting and hyphenation.

gcc/objc/ChangeLog:

	* objc-act.c (objc_build_setter_call): Adjust quoting and hyphenation.
	* objc-encoding.c (encode_gnu_bitfield): Same.

gcc/ChangeLog:

	* config/i386/i386-features.c (ix86_get_function_versions_dispatcher):
	Adjust quoting and hyphenation.
	* convert.c (convert_to_real_1): Same.
	* gcc.c (driver_wrong_lang_callback): Same.
	(driver::handle_unrecognized_options): Same.
	* gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same.
	* opts-common.c (cmdline_handle_error): Same.
	(read_cmdline_option): Same.
	* opts-global.c (complain_wrong_lang): Same.
	(print_ignored_options): Same.
	(handle_common_deferred_options): Same.
	* pretty-print.h: Same.
	* print-rtl.c (debug_bb_n_slim): Same.
	* sched-rgn.c (make_pass_sched_fusion): Same.
	* tree-cfg.c (verify_gimple_assign_unary): Same.
	(verify_gimple_label): Same.
	* tree-ssa-operands.c (verify_ssa_operands): Same.
	* varasm.c (do_assemble_alias): Same.
	(assemble_alias): Same.

	* diagnostic-core.h (GCC_DIAG_STYLE): Adjust.
	 (GCC_DIAG_RAW_STYLE): New macro.

	* cfghooks.c: Disable -Wformat-diags.
	* cfgloop.c: Same.
	* cfgrtl.c: Same.
	* cgraph.c: Same.
	* diagnostic-show-locus.c: Same.
	* diagnostic.c: Same.
	* gimple-pretty-print.c: Same.
	* graph.c: Same.
	* symtab.c: Same.
	* tree-eh.c Same.
	* tree-pretty-print.c: Same.
	* tree-ssa.c: Same.

	* configure: Regenerate.
	* configure.ac (ACX_PROG_CXX_WARNING_OPTS): Add -Wno-error=format-diag.
	 (ACX_PROG_CC_WARNING_OPTS): Same.

diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 03203470955..748653fd7f5 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -1821,7 +1821,7 @@ handle_mode_attribute (tree *node, tree name, tree args,
 	 this mode for this type.  */
 	  if (TREE_CODE (typefm) != INTEGER_TYPE)
 	{
-	  error ("cannot use mode %qs for enumeral types", p);
+	  error ("cannot use mode %qs for enumerated types", p);
 	  return NULL_TREE;
 	}
 
@@ -2326,12 +2326,8 @@ handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args,
 {
   struct symtab_node