On Wed, Jun 19, 2019 at 12:49 PM Martin Sebor <mse...@gmail.com> wrote: > > >>>> > >>>> gcc-wformat-diag-checker.diff > >>>> > >>>> gcc/c-family/ChangeLog: > >>>> > >>>> * c-format.c (function_format_info::format_type): Adjust type. > >>>> (function_format_info::is_raw): New member. > >>>> (decode_format_type): Adjust signature. Handle "raw" diag > >>>> attributes. > >>>> (decode_format_attr): Adjust call to decode_format_type. > >>>> Avoid a redundant call to convert_format_name_to_system_name. > >>>> Avoid abbreviating the word "arguments" in a diagnostic. > >>>> (format_warning_substr): New function. > >>>> (avoid_dollar_number): Quote dollar sign in a diagnostic. > >>>> (finish_dollar_format_checking): Same. > >>>> (check_format_info): Same. > >>>> (struct baltoks_t): New. > >>>> (c_opers, c_keywords, cxx_keywords, badwords, contrs): New arrays. > >>>> (maybe_diag_unbalanced_tokens, check_tokens, check_plain): New > >>>> functions. > >>>> (check_format_info_main): Call check_plain. Use baltoks_t. Call > >>>> maybe_diag_unbalanced_tokens. > >>>> (handle_format_attribute): Spell out the word "arguments" in > >>>> a diagnostic.
I want to mention that this is causing some false positive warnings when building the Go frontend (and a number of true positive warnings as well). The false positives don't break the build or anything, but it would be nice to avoid them. The escape analysis pass is emitting a format intended for debugging the compiler itself, when using -fgo-debug-escape. It produces warnings like the following. This output is fine. ../../gccgo/gcc/go/gofrontend/escape.cc: In member function ‘virtual int Escape_analysis_assign::statement(Block*, size_t*, Statement*)’: ../../gccgo/gcc/go/gofrontend/escape.cc:1336:33: warning: spurious leading punctuation sequence ‘[’ in format [-Wformat-diag] 1336 | go_inform(s->location(), "[%d] %s esc: %s", | ^ ../../gccgo/gcc/go/gofrontend/escape.cc: In member function ‘void Escape_analysis_assign::call(Call_expression*)’: ../../gccgo/gcc/go/gofrontend/escape.cc:1964:17: warning: unquoted operator ‘::’ in format [-Wformat-diag] 1964 | "esccall:: indirect call <- %s, untracked", | ^~ I see warnings saying that the keyword "float" should be quoted. But "float" is not a keyword in Go. For example, it would be pointless to quote float here: ../../gccgo/gcc/go/gofrontend/expressions.cc: In member function ‘bool Numeric_constant::check_float_type(Float_type*, bool, Location)’: ../../gccgo/gcc/go/gofrontend/expressions.cc:18980:68: warning: unquoted keyword ‘float’ in format [-Wformat-diag] 18980 | go_error_at(location, "complex constant truncated to float"); What is the best way to avoid these warnings when compiling the Go frontend? Thanks. Ian