Clean up -Wformat-diag warnings (PR bootstrap/97622, PR bootstrap/94982)
gcc/c-family/ChangeLog: PR bootstrap/94982 * c-attribs.c (handle_patchable_function_entry_attribute): Avoid -Wformat-diag. gcc/cp/ChangeLog: PR bootstrap/94982 * constraint.cc (debug_argument_list): Avoid -Wformat-diag. * error.c (function_category): Same. (print_template_differences): Same. * logic.cc (debug): Same. * name-lookup.c (lookup_using_decl): Same. * parser.c (maybe_add_cast_fixit): Same. (cp_parser_template_introduction): Same. * typeck.c (access_failure_info::add_fixit_hint): Same. gcc/ChangeLog: PR bootstrap/97622 PR bootstrap/94982 * config/i386/i386-options.c (ix86_valid_target_attribute_inner_p): Avoid -Wformat-diag. * digraph.cc (struct test_edge): Same. * dumpfile.c (dump_loc): Same. (dump_context::begin_scope): Same. * edit-context.c (edited_file::print_diff): Same. (edited_file::print_diff_hunk): Same. * json.cc (object::print): Same. * lto-wrapper.c (merge_and_complain): Same. * reload.c (find_reloads): Same. * tree-diagnostic-path.cc (print_path_summary_as_text): Same. * ubsan.c (ubsan_type_descriptor): Same. gcc/jit/ChangeLog: PR bootstrap/94982 * jit-recording.c (recording::function::dump_to_dot): Avoid -Wformat-diag. (recording::block::dump_to_dot): Same. gcc/testsuite/ChangeLog: PR bootstrap/94982 * c-c++-common/patchable_function_entry-error-3.c: Adjust text of expected warning.
This commit is contained in:
parent
15f82d80cf
commit
ca23341b28
@ -5191,8 +5191,8 @@ handle_patchable_function_entry_attribute (tree *, tree name, tree args,
|
||||
if (tree_to_uhwi (val) > USHRT_MAX)
|
||||
{
|
||||
warning (OPT_Wattributes,
|
||||
"%qE attribute argument %qE is out of range (> 65535)",
|
||||
name, val);
|
||||
"%qE attribute argument %qE exceeds %u",
|
||||
name, val, USHRT_MAX);
|
||||
*no_add_attrs = true;
|
||||
return NULL_TREE;
|
||||
}
|
||||
|
@ -1209,7 +1209,7 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
|
||||
{
|
||||
if (!opt_set_p)
|
||||
{
|
||||
error_at (loc, "pragma or attribute %<target(\"%s\")%> "
|
||||
error_at (loc, "pragma or attribute %<target(\"%s\")%> "
|
||||
"does not allow a negated form", p);
|
||||
return false;
|
||||
}
|
||||
@ -2077,7 +2077,7 @@ ix86_option_override_internal (bool main_args_p,
|
||||
&& (!TARGET_64BIT_P (opts->x_ix86_isa_flags)
|
||||
|| opts->x_ix86_abi != SYSV_ABI))
|
||||
{
|
||||
error (G_("%<%s%> architecture level is only defined"
|
||||
error (G_("%qs architecture level is only defined"
|
||||
" for the x86-64 psABI"), opts->x_ix86_arch_string);
|
||||
return false;
|
||||
}
|
||||
|
@ -533,9 +533,9 @@ debug_argument_list (tree args)
|
||||
{
|
||||
tree arg = TREE_VEC_ELT (args, i);
|
||||
if (TYPE_P (arg))
|
||||
verbatim ("ARG %qT", arg);
|
||||
verbatim ("argument %qT", arg);
|
||||
else
|
||||
verbatim ("ARG %qE", arg);
|
||||
verbatim ("argument %qE", arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3553,6 +3553,14 @@ function_category (tree fn)
|
||||
return _("In function %qs");
|
||||
}
|
||||
|
||||
/* Disable warnings about missing quoting in GCC diagnostics for
|
||||
the pp_verbatim calls. Their format strings deliberately don't
|
||||
follow GCC diagnostic conventions. */
|
||||
#if __GNUC__ >= 10
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wformat-diag"
|
||||
#endif
|
||||
|
||||
/* Report the full context of a current template instantiation,
|
||||
onto BUFFER. */
|
||||
static void
|
||||
@ -4053,6 +4061,10 @@ print_template_differences (pretty_printer *pp, tree type_a, tree type_b,
|
||||
pp_printf (pp, ">");
|
||||
}
|
||||
|
||||
#if __GNUC__ >= 10
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* As type_to_string, but for a template, potentially colorizing/eliding
|
||||
in comparison with PEER.
|
||||
For example, if TYPE is map<int,double> and PEER is map<int,int>,
|
||||
@ -4152,9 +4164,12 @@ add_quotes (const char *content, bool show_color)
|
||||
pretty_printer tmp_pp;
|
||||
pp_show_color (&tmp_pp) = show_color;
|
||||
|
||||
/* We have to use "%<%s%>" rather than "%qs" here in order to avoid
|
||||
quoting colorization bytes within the results. */
|
||||
pp_printf (&tmp_pp, "%<%s%>", content);
|
||||
/* We use pp_quote & pp_string rather than pp_printf with "%<%s%>"
|
||||
or "%qs" here in order to avoid quoting colorization bytes within
|
||||
the results, and to avoid -Wformat-diag. */
|
||||
pp_quote (&tmp_pp);
|
||||
pp_string (&tmp_pp, content);
|
||||
pp_quote (&tmp_pp);
|
||||
|
||||
return pp_ggc_formatted_text (&tmp_pp);
|
||||
}
|
||||
|
@ -303,9 +303,10 @@ debug (formula& f)
|
||||
{
|
||||
for (formula::iterator i = f.begin(); i != f.end(); ++i)
|
||||
{
|
||||
verbatim ("(((");
|
||||
/* Format punctuators via %s to avoid -Wformat-diag. */
|
||||
verbatim ("%s", "(((");
|
||||
debug (*i);
|
||||
verbatim (")))");
|
||||
verbatim ("%s", ")))");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4613,7 +4613,8 @@ lookup_using_decl (tree scope, name_lookup &lookup)
|
||||
{
|
||||
if (!TYPE_P (current))
|
||||
{
|
||||
error ("non-member using-decl names constructor of %qT", scope);
|
||||
error ("non-member using-declaration names constructor of %qT",
|
||||
scope);
|
||||
return NULL_TREE;
|
||||
}
|
||||
maybe_warn_cpp0x (CPP0X_INHERITING_CTORS);
|
||||
|
@ -9382,7 +9382,8 @@ maybe_add_cast_fixit (rich_location *rich_loc, location_t open_paren_loc,
|
||||
|
||||
/* Replace the open paren with "CAST_SUGGESTION<". */
|
||||
pretty_printer pp;
|
||||
pp_printf (&pp, "%s<", cast_suggestion);
|
||||
pp_string (&pp, cast_suggestion);
|
||||
pp_less (&pp);
|
||||
rich_loc->add_fixit_replace (open_paren_loc, pp_formatted_text (&pp));
|
||||
|
||||
/* Replace the close paren with "> (". */
|
||||
@ -29750,7 +29751,8 @@ cp_parser_template_introduction (cp_parser* parser, bool member_p)
|
||||
{
|
||||
if (!flag_concepts_ts)
|
||||
pedwarn (introduction_loc, 0, "template-introductions"
|
||||
" are not part of C++20 concepts [-fconcepts-ts]");
|
||||
" are not part of C++20 concepts; use %qs to enable",
|
||||
"-fconcepts-ts");
|
||||
|
||||
cp_parser_template_declaration_after_parameters (parser, parms,
|
||||
member_p);
|
||||
|
@ -2901,7 +2901,8 @@ access_failure_info::add_fixit_hint (rich_location *richloc,
|
||||
tree accessor_decl)
|
||||
{
|
||||
pretty_printer pp;
|
||||
pp_printf (&pp, "%s()", IDENTIFIER_POINTER (DECL_NAME (accessor_decl)));
|
||||
pp_string (&pp, IDENTIFIER_POINTER (DECL_NAME (accessor_decl)));
|
||||
pp_string (&pp, "()");
|
||||
richloc->add_fixit_replace (pp_formatted_text (&pp));
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ struct test_edge : public dedge<test_graph_traits>
|
||||
|
||||
void dump_dot (graphviz_out *gv, const dump_args_t &) const OVERRIDE
|
||||
{
|
||||
gv->println ("%s -> %s;", m_src->m_name, m_dest->m_name);
|
||||
gv->println ("%s %s %s%c", m_src->m_name, "->", m_dest->m_name, ';');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -492,6 +492,14 @@ dump_loc (dump_flags_t dump_kind, FILE *dfile, location_t loc)
|
||||
static void
|
||||
dump_loc (dump_flags_t dump_kind, pretty_printer *pp, location_t loc)
|
||||
{
|
||||
/* Disable warnings about missing quoting in GCC diagnostics for
|
||||
the pp_printf calls. Their format strings aren't used to format
|
||||
diagnostics so don't need to follow GCC diagnostic conventions. */
|
||||
#if __GNUC__ >= 10
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wformat-diag"
|
||||
#endif
|
||||
|
||||
if (dump_kind)
|
||||
{
|
||||
if (LOCATION_LOCUS (loc) > BUILTINS_LOCATION)
|
||||
@ -507,6 +515,10 @@ dump_loc (dump_flags_t dump_kind, pretty_printer *pp, location_t loc)
|
||||
for (unsigned i = 0; i < get_dump_scope_depth (); i++)
|
||||
pp_character (pp, ' ');
|
||||
}
|
||||
|
||||
#if __GNUC__ >= 10
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Implementation of dump_context member functions. */
|
||||
@ -1118,8 +1130,12 @@ dump_context::begin_scope (const char *name,
|
||||
if (m_test_pp && apply_dump_filter_p (MSG_NOTE, m_test_pp_flags))
|
||||
::dump_loc (MSG_NOTE, m_test_pp, src_loc);
|
||||
|
||||
/* Format multiple consecutive punctuation characters via %s to
|
||||
avoid -Wformat-diag in the pp_printf call below whose output
|
||||
isn't used for diagnostic output. */
|
||||
pretty_printer pp;
|
||||
pp_printf (&pp, "=== %s ===\n", name);
|
||||
pp_printf (&pp, "%s %s %s", "===", name, "===");
|
||||
pp_newline (&pp);
|
||||
optinfo_item *item
|
||||
= new optinfo_item (OPTINFO_ITEM_KIND_TEXT, UNKNOWN_LOCATION,
|
||||
xstrdup (pp_formatted_text (&pp)));
|
||||
|
@ -447,8 +447,13 @@ edited_file::print_diff (pretty_printer *pp, bool show_filenames)
|
||||
if (show_filenames)
|
||||
{
|
||||
pp_string (pp, colorize_start (pp_show_color (pp), "diff-filename"));
|
||||
pp_printf (pp, "--- %s\n", m_filename);
|
||||
pp_printf (pp, "+++ %s\n", m_filename);
|
||||
/* Avoid -Wformat-diag in non-diagnostic output. */
|
||||
pp_string (pp, "--- ");
|
||||
pp_string (pp, m_filename);
|
||||
pp_newline (pp);
|
||||
pp_string (pp, "+++ ");
|
||||
pp_string (pp, m_filename);
|
||||
pp_newline (pp);
|
||||
pp_string (pp, colorize_stop (pp_show_color (pp)));
|
||||
}
|
||||
|
||||
@ -519,8 +524,9 @@ edited_file::print_diff_hunk (pretty_printer *pp, int old_start_of_hunk,
|
||||
= get_effective_line_count (old_start_of_hunk, old_end_of_hunk);
|
||||
|
||||
pp_string (pp, colorize_start (pp_show_color (pp), "diff-hunk"));
|
||||
pp_printf (pp, "@@ -%i,%i +%i,%i @@\n", old_start_of_hunk, old_num_lines,
|
||||
new_start_of_hunk, new_num_lines);
|
||||
pp_printf (pp, "%s -%i,%i +%i,%i %s",
|
||||
"@@", old_start_of_hunk, old_num_lines,
|
||||
new_start_of_hunk, new_num_lines, "@@\n");
|
||||
pp_string (pp, colorize_stop (pp_show_color (pp)));
|
||||
|
||||
int line_num = old_start_of_hunk;
|
||||
|
@ -4038,8 +4038,8 @@ recording::function::dump_to_dot (const char *path)
|
||||
|
||||
pretty_printer *pp = &the_pp;
|
||||
|
||||
pp_printf (pp,
|
||||
"digraph %s {\n", get_debug_string ());
|
||||
pp_printf (pp, "digraph %s", get_debug_string ());
|
||||
pp_string (pp, " {\n");
|
||||
|
||||
/* Blocks: */
|
||||
{
|
||||
@ -4057,7 +4057,7 @@ recording::function::dump_to_dot (const char *path)
|
||||
b->dump_edges_to_dot (pp);
|
||||
}
|
||||
|
||||
pp_printf (pp, "}\n");
|
||||
pp_string (pp, "}\n");
|
||||
pp_flush (pp);
|
||||
fclose (fp);
|
||||
}
|
||||
@ -4479,6 +4479,14 @@ recording::block::write_reproducer (reproducer &r)
|
||||
m_name ? m_name->get_debug_string () : "NULL");
|
||||
}
|
||||
|
||||
/* Disable warnings about missing quoting in GCC diagnostics for
|
||||
the pp_printf calls. Their format strings deliberately don't
|
||||
follow GCC diagnostic conventions. */
|
||||
#if __GNUC__ >= 10
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wformat-diag"
|
||||
#endif
|
||||
|
||||
/* Dump a block in graphviz form into PP, capturing the block name (if
|
||||
any) and the statements. */
|
||||
|
||||
@ -4507,7 +4515,7 @@ recording::block::dump_to_dot (pretty_printer *pp)
|
||||
pp_write_text_as_dot_label_to_stream (pp, true /*for_record*/);
|
||||
}
|
||||
|
||||
pp_printf (pp,
|
||||
pp_string (pp,
|
||||
"}\"];\n\n");
|
||||
pp_flush (pp);
|
||||
}
|
||||
@ -4527,6 +4535,10 @@ recording::block::dump_edges_to_dot (pretty_printer *pp)
|
||||
successors.release ();
|
||||
}
|
||||
|
||||
#if __GNUC__ >= 10
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* The implementation of class gcc::jit::recording::global. */
|
||||
|
||||
/* Implementation of pure virtual hook recording::memento::replay_into
|
||||
|
@ -70,7 +70,10 @@ object::print (pretty_printer *pp) const
|
||||
pp_string (pp, ", ");
|
||||
const char *key = const_cast <char *>((*it).first);
|
||||
value *value = (*it).second;
|
||||
pp_printf (pp, "\"%s\": ", key); // FIXME: escaping?
|
||||
pp_doublequote (pp);
|
||||
pp_string (pp, key); // FIXME: escaping?
|
||||
pp_doublequote (pp);
|
||||
pp_string (pp, ": ");
|
||||
value->print (pp);
|
||||
}
|
||||
pp_character (pp, '}');
|
||||
|
@ -323,8 +323,9 @@ merge_and_complain (struct cl_decoded_option **decoded_options,
|
||||
if (cf_protection_option
|
||||
&& cf_protection_option->value == CF_CHECK)
|
||||
fatal_error (input_location,
|
||||
"option -fcf-protection with mismatching values"
|
||||
"option %qs with mismatching values"
|
||||
" (%s, %s)",
|
||||
"-fcf-protection",
|
||||
(*decoded_options)[j].arg, foption->arg);
|
||||
else
|
||||
{
|
||||
|
@ -2665,7 +2665,7 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known,
|
||||
if (i < recog_data.n_operands)
|
||||
{
|
||||
error_for_asm (insn,
|
||||
"the target does not support asm goto "
|
||||
"the target does not support %<asm goto%> "
|
||||
"with outputs in %<asm%>");
|
||||
ira_nullify_asm_goto (insn);
|
||||
return 0;
|
||||
|
@ -3,15 +3,15 @@
|
||||
|
||||
void
|
||||
__attribute__((patchable_function_entry(65536)))
|
||||
foo1 (void) { /* { dg-warning "'patchable_function_entry' attribute argument '65536' is out of range" } */
|
||||
foo1 (void) { /* { dg-warning "'patchable_function_entry' attribute argument '65536' exceeds 65535" } */
|
||||
}
|
||||
|
||||
void
|
||||
__attribute__((patchable_function_entry(65536,1)))
|
||||
foo2 (void) { /* { dg-warning "'patchable_function_entry' attribute argument '65536' is out of range" } */
|
||||
foo2 (void) { /* { dg-warning "'patchable_function_entry' attribute argument '65536' exceeds 65535" } */
|
||||
}
|
||||
|
||||
void
|
||||
__attribute__((patchable_function_entry(65536,65536)))
|
||||
foo3 (void) { /* { dg-warning "'patchable_function_entry' attribute argument '65536' is out of range" } */
|
||||
foo3 (void) { /* { dg-warning "'patchable_function_entry' attribute argument '65536' exceeds 65535" } */
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ print_path_summary_as_text (const path_summary *ps, diagnostic_context *dc,
|
||||
|
||||
write_indent (pp, vbar_for_next_frame);
|
||||
pp_string (pp, start_line_color);
|
||||
pp_printf (pp, "|");
|
||||
pp_character (pp, '|');
|
||||
pp_string (pp, end_line_color);
|
||||
pp_newline (pp);
|
||||
}
|
||||
@ -520,6 +520,13 @@ default_tree_make_json_for_path (diagnostic_context *context,
|
||||
|
||||
#if CHECKING_P
|
||||
|
||||
/* Disable warnings about missing quoting in GCC diagnostics for the print
|
||||
calls in the tests below. */
|
||||
#if __GNUC__ >= 10
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wformat-diag"
|
||||
#endif
|
||||
|
||||
namespace selftest {
|
||||
|
||||
/* A subclass of simple_diagnostic_path that adds member functions
|
||||
@ -814,4 +821,8 @@ tree_diagnostic_path_cc_tests ()
|
||||
|
||||
} // namespace selftest
|
||||
|
||||
#if __GNUC__ >= 10
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif /* #if CHECKING_P */
|
||||
|
13
gcc/ubsan.c
13
gcc/ubsan.c
@ -405,10 +405,12 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle)
|
||||
/* We weren't able to determine the type name. */
|
||||
tname = "<unknown>";
|
||||
|
||||
pp_quote (&pretty_name);
|
||||
|
||||
tree eltype = type;
|
||||
if (pstyle == UBSAN_PRINT_POINTER)
|
||||
{
|
||||
pp_printf (&pretty_name, "'%s%s%s%s%s%s%s",
|
||||
pp_printf (&pretty_name, "%s%s%s%s%s%s%s",
|
||||
TYPE_VOLATILE (type2) ? "volatile " : "",
|
||||
TYPE_READONLY (type2) ? "const " : "",
|
||||
TYPE_RESTRICT (type2) ? "restrict " : "",
|
||||
@ -420,14 +422,14 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle)
|
||||
deref_depth == 0 ? "" : " ");
|
||||
while (deref_depth-- > 0)
|
||||
pp_star (&pretty_name);
|
||||
pp_quote (&pretty_name);
|
||||
}
|
||||
else if (pstyle == UBSAN_PRINT_ARRAY)
|
||||
{
|
||||
/* Pretty print the array dimensions. */
|
||||
gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
|
||||
tree t = type;
|
||||
pp_printf (&pretty_name, "'%s ", tname);
|
||||
pp_string (&pretty_name, tname);
|
||||
pp_space (&pretty_name);
|
||||
while (deref_depth-- > 0)
|
||||
pp_star (&pretty_name);
|
||||
while (TREE_CODE (t) == ARRAY_TYPE)
|
||||
@ -453,13 +455,14 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle)
|
||||
pp_right_bracket (&pretty_name);
|
||||
t = TREE_TYPE (t);
|
||||
}
|
||||
pp_quote (&pretty_name);
|
||||
|
||||
/* Save the tree with stripped types. */
|
||||
eltype = t;
|
||||
}
|
||||
else
|
||||
pp_printf (&pretty_name, "'%s'", tname);
|
||||
pp_string (&pretty_name, tname);
|
||||
|
||||
pp_quote (&pretty_name);
|
||||
|
||||
switch (TREE_CODE (eltype))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user