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;
}
{
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;
}
&& (!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;
}
{
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);
}
}
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
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>,
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);
}
{
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", ")))");
}
}
{
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);
/* 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 "> (". */
{
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);
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));
}
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, ';');
}
};
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)
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. */
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)));
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)));
}
= 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;
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: */
{
b->dump_edges_to_dot (pp);
}
- pp_printf (pp, "}\n");
+ pp_string (pp, "}\n");
pp_flush (pp);
fclose (fp);
}
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. */
pp_write_text_as_dot_label_to_stream (pp, true /*for_record*/);
}
- pp_printf (pp,
+ pp_string (pp,
"}\"];\n\n");
pp_flush (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
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, '}');
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
{
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;
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" } */
}
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);
}
#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
} // namespace selftest
+#if __GNUC__ >= 10
+# pragma GCC diagnostic pop
+#endif
+
#endif /* #if CHECKING_P */
/* 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 " : "",
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)
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))
{