aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/Makefile.in2
-rw-r--r--libcpp/charset.cc56
-rw-r--r--libcpp/directives.cc151
-rw-r--r--libcpp/errors.cc6
-rw-r--r--libcpp/expr.cc75
-rw-r--r--libcpp/files.cc15
-rw-r--r--libcpp/include/cpplib.h33
-rw-r--r--libcpp/init.cc11
-rw-r--r--libcpp/lex.cc52
-rw-r--r--libcpp/macro.cc80
-rw-r--r--libcpp/pch.cc18
-rw-r--r--libcpp/traditional.cc4
12 files changed, 263 insertions, 240 deletions
diff --git a/libcpp/Makefile.in b/libcpp/Makefile.in
index 7e47153..eff0dd6 100644
--- a/libcpp/Makefile.in
+++ b/libcpp/Makefile.in
@@ -263,7 +263,7 @@ po/$(PACKAGE).pot: $(libcpp_a_SOURCES)
--keyword=SYNTAX_ERROR --keyword=SYNTAX_ERROR2 \
--copyright-holder="Free Software Foundation, Inc." \
--msgid-bugs-address="https://gcc.gnu.org/bugs/" \
- --language=c -o po/$(PACKAGE).pot.tmp $^
+ --language=GCC-source -o po/$(PACKAGE).pot.tmp $^
sed 's:$(srcdir)/::g' <po/$(PACKAGE).pot.tmp >po/$(PACKAGE).pot
rm po/$(PACKAGE).pot.tmp
diff --git a/libcpp/charset.cc b/libcpp/charset.cc
index 32b6fd5..c7d4508 100644
--- a/libcpp/charset.cc
+++ b/libcpp/charset.cc
@@ -867,8 +867,8 @@ cpp_host_to_exec_charset (cpp_reader *pfile, cppchar_t c)
if (c > LAST_POSSIBLY_BASIC_SOURCE_CHAR)
{
cpp_error (pfile, CPP_DL_ICE,
- "character 0x%lx is not in the basic source character set\n",
- (unsigned long)c);
+ "character 0x%lx is not in the basic source character set",
+ (unsigned long) c);
return 0;
}
@@ -1550,10 +1550,10 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
else if (CPP_OPTION (pfile, cpp_warn_c90_c99_compat) > 0
&& !CPP_OPTION (pfile, cplusplus))
cpp_error (pfile, CPP_DL_WARNING,
- "C99's universal character names are incompatible with C90");
+ "C99%'s universal character names are incompatible with C90");
else if (CPP_WTRADITIONAL (pfile) && identifier_pos == 0)
cpp_warning (pfile, CPP_W_TRADITIONAL,
- "the meaning of '\\%c' is different in traditional C",
+ "the meaning of %<\\%c%> is different in traditional C",
(int) str[-1]);
result = 0;
@@ -1592,7 +1592,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
*cp = 0;
return false;
}
- cpp_error (pfile, CPP_DL_ERROR, "'\\N' not followed by '{'");
+ cpp_error (pfile, CPP_DL_ERROR, "%<\\N%> not followed by %<{%>");
}
else
{
@@ -1656,13 +1656,13 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
&& (!CPP_OPTION (pfile, delimited_escape_seqs)
|| !strict))
ret = cpp_warning (pfile, CPP_W_UNICODE,
- "\\N{%.*s} is not a valid "
+ "%<\\N{%.*s}%> is not a valid "
"universal character; treating it "
"as separate tokens",
(int) (str - name), name);
else
cpp_error (pfile, CPP_DL_ERROR,
- "\\N{%.*s} is not a valid universal "
+ "%<\\N{%.*s}%> is not a valid universal "
"character", (int) (str - name), name);
/* Try to do a loose name lookup according to
@@ -1672,7 +1672,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
str - name, canon_name);
if (result != (cppchar_t) -1 && ret)
cpp_error (pfile, CPP_DL_NOTE,
- "did you mean \\N{%s}?", canon_name);
+ "did you mean %<\\N{%s}%>?", canon_name);
else
result = 0xC0;
if (identifier_pos
@@ -1690,7 +1690,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
else if (identifier_pos)
{
cpp_warning (pfile, CPP_W_UNICODE,
- "'\\N{' not terminated with '}' after %.*s; "
+ "%<\\N{%> not terminated with %<}%> after %.*s; "
"treating it as separate tokens",
(int) (str - base), base);
*cp = 0;
@@ -1699,7 +1699,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
else
{
cpp_error (pfile, CPP_DL_ERROR,
- "'\\N{' not terminated with '}' after %.*s",
+ "%<\\N{%> not terminated with %<}%> after %.*s",
(int) (str - base), base);
result = 1;
}
@@ -1707,7 +1707,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
}
else
{
- cpp_error (pfile, CPP_DL_ICE, "In _cpp_valid_ucn but not a UCN");
+ cpp_error (pfile, CPP_DL_ICE, "in %<_cpp_valid_ucn%> but not a UCN");
length = 4;
}
@@ -1775,7 +1775,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
{
if (delimited)
cpp_warning (pfile, CPP_W_UNICODE,
- "'\\u{' not terminated with '}' after %.*s; "
+ "%<\\u{%> not terminated with %<}%> after %.*s; "
"treating it as separate tokens",
(int) (str - base), base);
*cp = 0;
@@ -1791,7 +1791,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
(int) (str - base), base);
else
cpp_error (pfile, CPP_DL_ERROR,
- "'\\u{' not terminated with '}' after %.*s",
+ "%<\\u{%> not terminated with %<}%> after %.*s",
(int) (str - base), base);
result = 1;
}
@@ -1821,7 +1821,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
if (CPP_OPTION (pfile, warn_dollars) && !pfile->state.skipping)
{
CPP_OPTION (pfile, warn_dollars) = 0;
- cpp_error (pfile, CPP_DL_PEDWARN, "'$' in identifier or number");
+ cpp_error (pfile, CPP_DL_PEDWARN, "%<$%> in identifier or number");
}
NORMALIZE_STATE_UPDATE_IDNUM (nst, result);
}
@@ -2096,7 +2096,7 @@ convert_hex (cpp_reader *pfile, const uchar *from, const uchar *limit,
if (CPP_WTRADITIONAL (pfile))
cpp_warning (pfile, CPP_W_TRADITIONAL,
- "the meaning of '\\x' is different in traditional C");
+ "the meaning of %<\\x%> is different in traditional C");
/* Skip 'x'. */
from++;
@@ -2144,13 +2144,13 @@ convert_hex (cpp_reader *pfile, const uchar *from, const uchar *limit,
if (!digits_found)
{
cpp_error (pfile, CPP_DL_ERROR,
- "\\x used with no following hex digits");
+ "%<\\x%> used with no following hex digits");
return from;
}
else if (delimited)
{
cpp_error (pfile, CPP_DL_ERROR,
- "'\\x{' not terminated with '}' after %.*s",
+ "%<\\x{%> not terminated with %<}%> after %.*s",
(int) (from - base), base);
return from;
}
@@ -2201,7 +2201,7 @@ convert_oct (cpp_reader *pfile, const uchar *from, const uchar *limit,
from++;
extend_char_range (&char_range, loc_reader);
if (from == limit || *from != '{')
- cpp_error (pfile, CPP_DL_ERROR, "'\\o' not followed by '{'");
+ cpp_error (pfile, CPP_DL_ERROR, "%<\\o%> not followed by %<}%>");
else
{
from++;
@@ -2247,7 +2247,7 @@ convert_oct (cpp_reader *pfile, const uchar *from, const uchar *limit,
else
{
cpp_error (pfile, CPP_DL_ERROR,
- "'\\o{' not terminated with '}' after %.*s",
+ "%<\\o{%> not terminated with %<}%> after %.*s",
(int) (from - base), base);
return from;
}
@@ -2309,7 +2309,7 @@ convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit,
if (uneval)
cpp_pedwarning (pfile, CPP_W_PEDANTIC,
"numeric escape sequence in unevaluated string: "
- "'\\%c'", (int) c);
+ "%<\\%c%>", (int) c);
return convert_hex (pfile, from, limit, tbuf, cvt,
char_range, loc_reader, ranges);
@@ -2319,7 +2319,7 @@ convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit,
if (uneval)
cpp_pedwarning (pfile, CPP_W_PEDANTIC,
"numeric escape sequence in unevaluated string: "
- "'\\%c'", (int) c);
+ "%<\\%c%>", (int) c);
return convert_oct (pfile, from, limit, tbuf, cvt,
char_range, loc_reader, ranges);
@@ -2346,13 +2346,13 @@ convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit,
case 'a':
if (CPP_WTRADITIONAL (pfile))
cpp_warning (pfile, CPP_W_TRADITIONAL,
- "the meaning of '\\a' is different in traditional C");
+ "the meaning of %<\\a%> is different in traditional C");
c = charconsts[0];
break;
case 'e': case 'E':
cpp_pedwarning (pfile, CPP_W_PEDANTIC,
- "non-ISO-standard escape sequence, '\\%c'", (int) c);
+ "non-ISO-standard escape sequence, %<\\%c%>", (int) c);
c = charconsts[2];
break;
@@ -2360,7 +2360,7 @@ convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit,
unknown:
if (ISGRAPH (c))
cpp_error (pfile, CPP_DL_PEDWARN,
- "unknown escape sequence: '\\%c'", (int) c);
+ "unknown escape sequence: %<\\%c%>", (int) c);
else
{
encoding_rich_location rich_loc (pfile);
@@ -2370,7 +2370,7 @@ convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit,
char buf[32];
sprintf(buf, "%03o", (int) c);
cpp_error_at (pfile, CPP_DL_PEDWARN, &rich_loc,
- "unknown escape sequence: '\\%s'", buf);
+ "unknown escape sequence: %<\\%s%>", buf);
}
}
@@ -2655,7 +2655,7 @@ cpp_interpret_string_ranges (cpp_reader *pfile, const cpp_string *from,
bool (*saved_diagnostic_handler) (cpp_reader *, enum cpp_diagnostic_level,
enum cpp_warning_reason, rich_location *,
const char *, va_list *)
- ATTRIBUTE_FPTR_PRINTF(5,0);
+ ATTRIBUTE_CPP_PPDIAG (5, 0);
saved_diagnostic_handler = pfile->cb.diagnostic;
pfile->cb.diagnostic = noop_diagnostic_cb;
@@ -2704,7 +2704,7 @@ count_source_chars (cpp_reader *pfile, cpp_string str, cpp_ttype type)
bool (*saved_diagnostic_handler) (cpp_reader *, enum cpp_diagnostic_level,
enum cpp_warning_reason, rich_location *,
const char *, va_list *)
- ATTRIBUTE_FPTR_PRINTF(5,0);
+ ATTRIBUTE_CPP_PPDIAG (5, 0);
saved_diagnostic_handler = pfile->cb.diagnostic;
pfile->cb.diagnostic = noop_diagnostic_cb;
convert_f save_func = pfile->narrow_cset_desc.func;
@@ -2803,7 +2803,7 @@ narrow_str_to_charconst (cpp_reader *pfile, cpp_string str,
if (type != CPP_UTF8CHAR)
cpp_error (pfile, CPP_DL_WARNING,
"multi-character literal with %ld characters exceeds "
- "'int' size of %ld bytes", (long) i, (long) max_chars);
+ "%<int%> size of %ld bytes", (long) i, (long) max_chars);
else if (src_chars > 2)
cpp_error (pfile, CPP_DL_ERROR,
"multi-character literal cannot have an encoding prefix");
diff --git a/libcpp/directives.cc b/libcpp/directives.cc
index 9c906b3..50fa8ace2 100644
--- a/libcpp/directives.cc
+++ b/libcpp/directives.cc
@@ -239,7 +239,7 @@ check_eol_1 (cpp_reader *pfile, bool expand, enum cpp_warning_reason reason)
if (! SEEN_EOL () && (expand
? cpp_get_token (pfile)
: _cpp_lex_token (pfile))->type != CPP_EOF)
- cpp_pedwarning (pfile, reason, "extra tokens at end of #%s directive",
+ cpp_pedwarning (pfile, reason, "extra tokens at end of %<#%s%> directive",
pfile->directive->name);
}
@@ -391,8 +391,8 @@ directive_diagnostics (cpp_reader *pfile, const directive *dir, int indented)
if (dir->origin == EXTENSION
&& !(dir == &dtable[T_IMPORT] && CPP_OPTION (pfile, objc)))
warned
- = cpp_pedwarning (pfile, CPP_W_PEDANTIC, "#%s is a GCC extension",
- dir->name);
+ = cpp_pedwarning (pfile, CPP_W_PEDANTIC,
+ "%<#%s%> is a GCC extension", dir->name);
if (!warned && dir == &dtable[T_WARNING])
{
if (CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, warning_directive))
@@ -400,18 +400,18 @@ directive_diagnostics (cpp_reader *pfile, const directive *dir, int indented)
if (CPP_OPTION (pfile, cplusplus))
warned
= cpp_pedwarning (pfile, CPP_W_CXX23_EXTENSIONS,
- "#%s before C++23 is a GCC extension",
+ "%<#%s%> before C++23 is a GCC extension",
dir->name);
else
warned
= cpp_pedwarning (pfile, CPP_W_PEDANTIC,
- "#%s before C23 is a GCC extension",
+ "%<#%s%> before C23 is a GCC extension",
dir->name);
}
if (!warned && CPP_OPTION (pfile, cpp_warn_c11_c23_compat) > 0)
warned = cpp_warning (pfile, CPP_W_C11_C23_COMPAT,
- "#%s before C23 is a GCC extension",
+ "%<#%s%> before C23 is a GCC extension",
dir->name);
}
@@ -419,7 +419,7 @@ directive_diagnostics (cpp_reader *pfile, const directive *dir, int indented)
|| (dir == &dtable[T_IMPORT] && !CPP_OPTION (pfile, objc)))
&& !warned)
cpp_warning (pfile, CPP_W_DEPRECATED,
- "#%s is a deprecated GCC extension", dir->name);
+ "%<#%s%> is a deprecated GCC extension", dir->name);
}
/* Traditionally, a directive is ignored unless its # is in
@@ -432,15 +432,15 @@ directive_diagnostics (cpp_reader *pfile, const directive *dir, int indented)
{
if (dir == &dtable[T_ELIF])
cpp_warning (pfile, CPP_W_TRADITIONAL,
- "suggest not using #elif in traditional C");
+ "suggest not using %<#elif%> in traditional C");
else if (indented && dir->origin == KANDR)
cpp_warning (pfile, CPP_W_TRADITIONAL,
- "traditional C ignores #%s with the # indented",
+ "traditional C ignores %<#%s%> with the %<#%> indented",
dir->name);
else if (!indented && dir->origin != KANDR)
cpp_warning (pfile, CPP_W_TRADITIONAL,
- "suggest hiding #%s from traditional C with an indented #",
- dir->name);
+ "suggest hiding %<#%s%> from traditional C with an "
+ "indented %<#%>", dir->name);
}
}
@@ -652,17 +652,17 @@ lex_macro_node (cpp_reader *pfile, bool is_def_or_undef)
if (is_def_or_undef
&& node == pfile->spec_nodes.n_defined)
cpp_error (pfile, CPP_DL_ERROR,
- "\"%s\" cannot be used as a macro name",
+ "%qs cannot be used as a macro name",
NODE_NAME (node));
else if (! (node->flags & NODE_POISONED))
return node;
}
else if (token->flags & NAMED_OP)
cpp_error (pfile, CPP_DL_ERROR,
- "\"%s\" cannot be used as a macro name as it is an operator in C++",
- NODE_NAME (token->val.node.node));
+ "%qs cannot be used as a macro name as it is an operator "
+ "in C++", NODE_NAME (token->val.node.node));
else if (token->type == CPP_EOF)
- cpp_error (pfile, CPP_DL_ERROR, "no macro name given in #%s directive",
+ cpp_error (pfile, CPP_DL_ERROR, "no macro name given in %<#%s%> directive",
pfile->directive->name);
else
cpp_error (pfile, CPP_DL_ERROR, "macro names must be identifiers");
@@ -739,11 +739,11 @@ do_undef (cpp_reader *pfile)
{
if (node->flags & NODE_WARN)
cpp_error (pfile, CPP_DL_WARNING,
- "undefining \"%s\"", NODE_NAME (node));
+ "undefining %qs", NODE_NAME (node));
else if (cpp_builtin_macro_p (node)
&& CPP_OPTION (pfile, warn_builtin_macro_redefined))
cpp_warning (pfile, CPP_W_BUILTIN_MACRO_REDEFINED,
- "undefining \"%s\"", NODE_NAME (node));
+ "undefining %qs", NODE_NAME (node));
if (node->value.macro
&& CPP_OPTION (pfile, warn_unused_macros))
@@ -800,7 +800,8 @@ glue_header_name (cpp_reader *pfile)
break;
if (token->type == CPP_EOF)
{
- cpp_error (pfile, CPP_DL_ERROR, "missing terminating > character");
+ cpp_error (pfile, CPP_DL_ERROR,
+ "missing terminating %<>%> character");
break;
}
@@ -856,11 +857,11 @@ parse_include (cpp_reader *pfile, int *pangle_brackets,
const unsigned char *dir;
if (pfile->directive == &dtable[T_PRAGMA])
- dir = UC"pragma dependency";
+ dir = UC"pragma GCC dependency";
else
dir = pfile->directive->name;
- cpp_error (pfile, CPP_DL_ERROR, "#%s expects \"FILENAME\" or <FILENAME>",
- dir);
+ cpp_error (pfile, CPP_DL_ERROR,
+ "%<#%s%> expects %<\"FILENAME\"%> or %<<FILENAME>%>", dir);
return NULL;
}
@@ -915,8 +916,8 @@ do_include_common (cpp_reader *pfile, enum include_type type)
if (pfile->line_table->depth >= CPP_OPTION (pfile, max_include_depth))
cpp_error (pfile,
CPP_DL_ERROR,
- "#include nested depth %u exceeds maximum of %u"
- " (use -fmax-include-depth=DEPTH to increase the maximum)",
+ "%<#include%> nested depth %u exceeds maximum of %u"
+ " (use %<-fmax-include-depth=DEPTH%> to increase the maximum)",
pfile->line_table->depth,
CPP_OPTION (pfile, max_include_depth));
else
@@ -960,7 +961,7 @@ do_include_next (cpp_reader *pfile)
if (_cpp_in_main_source_file (pfile))
{
cpp_error (pfile, CPP_DL_WARNING,
- "#include_next in primary source file");
+ "%<#include_next%> in primary source file");
type = IT_INCLUDE;
}
do_include_common (pfile, type);
@@ -1115,7 +1116,7 @@ _cpp_parse_embed_params (cpp_reader *pfile, struct cpp_embed_params *params)
{
if (params->has_embed)
{
- cpp_error (pfile, CPP_DL_ERROR, "expected ')'");
+ cpp_error (pfile, CPP_DL_ERROR, "expected %<)%>");
return false;
}
}
@@ -1132,8 +1133,9 @@ _cpp_parse_embed_params (cpp_reader *pfile, struct cpp_embed_params *params)
if (!params->has_embed)
cpp_error_with_line (pfile, CPP_DL_ERROR,
params->base64.base_run.base->src_loc, 0,
- "'gnu::base64' parameter conflicts with "
- "'limit' or 'gnu::offset' parameters");
+ "%<gnu::base64%> parameter conflicts "
+ "with %<limit%> or %<gnu::offset%> "
+ "parameters");
}
else if (params->base64.count == 0
&& CPP_OPTION (pfile, preprocessed))
@@ -1141,7 +1143,7 @@ _cpp_parse_embed_params (cpp_reader *pfile, struct cpp_embed_params *params)
ret = false;
if (!params->has_embed)
cpp_error_with_line (pfile, CPP_DL_ERROR, params->loc, 0,
- "'gnu::base64' parameter required in "
+ "%<gnu::base64%> parameter required in "
"preprocessed source");
}
return ret;
@@ -1162,7 +1164,7 @@ _cpp_parse_embed_params (cpp_reader *pfile, struct cpp_embed_params *params)
token = _cpp_get_token_no_padding (pfile);
if (token->type != CPP_COLON)
{
- cpp_error (pfile, CPP_DL_ERROR, "expected ':'");
+ cpp_error (pfile, CPP_DL_ERROR, "expected %<:%>");
return false;
}
token = _cpp_get_token_no_padding (pfile);
@@ -1250,7 +1252,7 @@ _cpp_parse_embed_params (cpp_reader *pfile, struct cpp_embed_params *params)
}
if (param_kind != (size_t) -1 && token->type != CPP_OPEN_PAREN)
cpp_error_with_line (pfile, CPP_DL_ERROR, loc, 0,
- "expected '('");
+ "expected %<(%>");
else if (param_kind == EMBED_PARAM_LIMIT
|| param_kind == EMBED_PARAM_GNU_OFFSET)
{
@@ -1263,7 +1265,7 @@ _cpp_parse_embed_params (cpp_reader *pfile, struct cpp_embed_params *params)
{
if (res > INTTYPE_MAXIMUM (off_t))
cpp_error_with_line (pfile, CPP_DL_ERROR, loc, 0,
- "too large 'gnu::offset' argument");
+ "too large %<gnu::offset%> argument");
else
params->offset = res;
}
@@ -1305,7 +1307,7 @@ _cpp_parse_embed_params (cpp_reader *pfile, struct cpp_embed_params *params)
while (token->type == CPP_STRING);
if (token->type != CPP_CLOSE_PAREN)
cpp_error_with_line (pfile, CPP_DL_ERROR, token->src_loc, 0,
- "expected ')'");
+ "expected %<)%>");
}
else
{
@@ -1355,7 +1357,7 @@ do_embed (cpp_reader *pfile)
if (CPP_OPTION (pfile, traditional))
{
cpp_error (pfile, CPP_DL_ERROR, /* FIXME should be DL_SORRY */
- "#embed not supported in traditional C");
+ "%<#embed%> not supported in traditional C");
skip_rest_of_line (pfile);
goto done;
}
@@ -1364,10 +1366,10 @@ do_embed (cpp_reader *pfile)
{
if (CPP_OPTION (pfile, cplusplus))
cpp_error (pfile, CPP_DL_PEDWARN,
- "#%s is a GCC extension", "embed");
+ "%<#%s%> is a GCC extension", "embed");
else
cpp_error (pfile, CPP_DL_PEDWARN,
- "#%s before C23 is a GCC extension", "embed");
+ "%<#%s%> before C23 is a GCC extension", "embed");
}
fname = parse_include (pfile, &angle_brackets, NULL, &params.loc);
@@ -1425,7 +1427,7 @@ read_flag (cpp_reader *pfile, unsigned int last)
}
if (token->type != CPP_EOF)
- cpp_error (pfile, CPP_DL_ERROR, "invalid flag \"%s\" in line directive",
+ cpp_error (pfile, CPP_DL_ERROR, "invalid flag %qs in line directive",
cpp_token_as_text (pfile, token));
return 0;
}
@@ -1492,10 +1494,11 @@ do_line (cpp_reader *pfile)
&new_lineno, &wrapped))
{
if (token->type == CPP_EOF)
- cpp_error (pfile, CPP_DL_ERROR, "unexpected end of file after #line");
+ cpp_error (pfile, CPP_DL_ERROR,
+ "unexpected end of file after %<#line%>");
else
cpp_error (pfile, CPP_DL_ERROR,
- "\"%s\" after #line is not a positive integer",
+ "%qs after %<#line%> is not a positive integer",
cpp_token_as_text (pfile, token));
return;
}
@@ -1517,7 +1520,7 @@ do_line (cpp_reader *pfile)
}
else if (token->type != CPP_EOF)
{
- cpp_error (pfile, CPP_DL_ERROR, "\"%s\" is not a valid filename",
+ cpp_error (pfile, CPP_DL_ERROR, "%qs is not a valid filename",
cpp_token_as_text (pfile, token));
return;
}
@@ -1558,7 +1561,7 @@ do_linemarker (cpp_reader *pfile)
/* Unlike #line, there does not seem to be a way to get an EOF
here. So, it should be safe to always spell the token. */
cpp_error (pfile, CPP_DL_ERROR,
- "\"%s\" after # is not a positive integer",
+ "%qs after %<#%> is not a positive integer",
cpp_token_as_text (pfile, token));
return;
}
@@ -1598,7 +1601,7 @@ do_linemarker (cpp_reader *pfile)
}
else if (token->type != CPP_EOF)
{
- cpp_error (pfile, CPP_DL_ERROR, "\"%s\" is not a valid filename",
+ cpp_error (pfile, CPP_DL_ERROR, "%qs is not a valid filename",
cpp_token_as_text (pfile, token));
return;
}
@@ -1625,7 +1628,7 @@ do_linemarker (cpp_reader *pfile)
if (!from)
{
cpp_warning (pfile, CPP_W_NONE,
- "file \"%s\" linemarker ignored due to "
+ "file %qs linemarker ignored due to "
"incorrect nesting", new_file);
return;
}
@@ -1794,7 +1797,7 @@ register_pragma_1 (cpp_reader *pfile, const char *space, const char *name,
else if (entry->allow_expansion != allow_name_expansion)
{
cpp_error (pfile, CPP_DL_ICE,
- "registering pragmas in namespace \"%s\" with mismatched "
+ "registering pragmas in namespace %qs with mismatched "
"name expansion", space);
return NULL;
}
@@ -1803,7 +1806,7 @@ register_pragma_1 (cpp_reader *pfile, const char *space, const char *name,
else if (allow_name_expansion)
{
cpp_error (pfile, CPP_DL_ICE,
- "registering pragma \"%s\" with name expansion "
+ "registering pragma %qs with name expansion "
"and no namespace", name);
return NULL;
}
@@ -1821,13 +1824,14 @@ register_pragma_1 (cpp_reader *pfile, const char *space, const char *name,
if (entry->is_nspace)
clash:
cpp_error (pfile, CPP_DL_ICE,
- "registering \"%s\" as both a pragma and a pragma namespace",
+ "registering %qs as both a pragma and a pragma namespace",
NODE_NAME (node));
else if (space)
- cpp_error (pfile, CPP_DL_ICE, "#pragma %s %s is already registered",
+ cpp_error (pfile, CPP_DL_ICE, "%<#pragma %s %s%> is already registered",
space, name);
else
- cpp_error (pfile, CPP_DL_ICE, "#pragma %s is already registered", name);
+ cpp_error (pfile, CPP_DL_ICE, "%<#pragma %s%> is already registered",
+ name);
return NULL;
}
@@ -2075,7 +2079,7 @@ do_pragma_once (cpp_reader *pfile)
{
if (_cpp_in_main_source_file (pfile))
cpp_warning (pfile, CPP_W_PRAGMA_ONCE_OUTSIDE_HEADER,
- "'#pragma once' in main file");
+ "%<#pragma once%> in main file");
check_eol (pfile, false);
_cpp_mark_file_once_only (pfile, pfile->buffer->file);
@@ -2098,7 +2102,7 @@ do_pragma_push_macro (cpp_reader *pfile)
{
location_t src_loc = pfile->cur_token[-1].src_loc;
cpp_error_with_line (pfile, CPP_DL_ERROR, src_loc, 0,
- "invalid #pragma push_macro directive");
+ "invalid %<#pragma push_macro%> directive");
check_eol (pfile, false);
skip_rest_of_line (pfile);
return;
@@ -2155,7 +2159,7 @@ do_pragma_pop_macro (cpp_reader *pfile)
{
location_t src_loc = pfile->cur_token[-1].src_loc;
cpp_error_with_line (pfile, CPP_DL_ERROR, src_loc, 0,
- "invalid #pragma pop_macro directive");
+ "invalid %<#pragma pop_macro%> directive");
check_eol (pfile, false);
skip_rest_of_line (pfile);
return;
@@ -2210,7 +2214,7 @@ do_pragma_poison (cpp_reader *pfile)
if (tok->type != CPP_NAME)
{
cpp_error (pfile, CPP_DL_ERROR,
- "invalid #pragma GCC poison directive");
+ "invalid %<#pragma GCC poison%> directive");
break;
}
@@ -2219,7 +2223,7 @@ do_pragma_poison (cpp_reader *pfile)
continue;
if (cpp_macro_p (hp))
- cpp_error (pfile, CPP_DL_WARNING, "poisoning existing macro \"%s\"",
+ cpp_error (pfile, CPP_DL_WARNING, "poisoning existing macro %qs",
NODE_NAME (hp));
_cpp_free_definition (hp);
hp->flags |= NODE_POISONED | NODE_DIAGNOSTIC;
@@ -2241,7 +2245,7 @@ do_pragma_system_header (cpp_reader *pfile)
{
if (_cpp_in_main_source_file (pfile))
cpp_error (pfile, CPP_DL_WARNING,
- "#pragma system_header ignored outside include file");
+ "%<#pragma system_header%> ignored outside include file");
else
{
check_eol (pfile, false);
@@ -2294,7 +2298,7 @@ do_pragma_warning_or_error (cpp_reader *pfile, bool error)
CPP_STRING)
|| str.len == 0)
{
- cpp_error (pfile, CPP_DL_ERROR, "invalid \"#pragma GCC %s\" directive",
+ cpp_error (pfile, CPP_DL_ERROR, "invalid %<#pragma GCC %s%> directive",
error ? "error" : "warning");
return;
}
@@ -2502,7 +2506,7 @@ _cpp_do__Pragma (cpp_reader *pfile, location_t expansion_loc)
return 1;
}
cpp_error (pfile, CPP_DL_ERROR,
- "_Pragma takes a parenthesized string literal");
+ "%<_Pragma%> takes a parenthesized string literal");
return 0;
}
@@ -2585,12 +2589,12 @@ do_else (cpp_reader *pfile)
struct if_stack *ifs = buffer->if_stack;
if (ifs == NULL)
- cpp_error (pfile, CPP_DL_ERROR, "#else without #if");
+ cpp_error (pfile, CPP_DL_ERROR, "%<#else%> without %<#if%>");
else
{
if (ifs->type == T_ELSE)
{
- cpp_error (pfile, CPP_DL_ERROR, "#else after #else");
+ cpp_error (pfile, CPP_DL_ERROR, "%<#else%> after %<#else%>");
cpp_error_with_line (pfile, CPP_DL_ERROR, ifs->line, 0,
"the conditional began here");
}
@@ -2618,12 +2622,13 @@ do_elif (cpp_reader *pfile)
struct if_stack *ifs = buffer->if_stack;
if (ifs == NULL)
- cpp_error (pfile, CPP_DL_ERROR, "#%s without #if", pfile->directive->name);
+ cpp_error (pfile, CPP_DL_ERROR, "%<#%s%> without %<#if%>",
+ pfile->directive->name);
else
{
if (ifs->type == T_ELSE)
{
- cpp_error (pfile, CPP_DL_ERROR, "#%s after #else",
+ cpp_error (pfile, CPP_DL_ERROR, "%<#%s%> after %<#else%>",
pfile->directive->name);
cpp_error_with_line (pfile, CPP_DL_ERROR, ifs->line, 0,
"the conditional began here");
@@ -2646,11 +2651,11 @@ do_elif (cpp_reader *pfile)
{
if (CPP_OPTION (pfile, cplusplus))
cpp_pedwarning (pfile, CPP_W_CXX23_EXTENSIONS,
- "#%s before C++23 is a GCC extension",
+ "%<#%s%> before C++23 is a GCC extension",
pfile->directive->name);
else
cpp_pedwarning (pfile, CPP_W_PEDANTIC,
- "#%s before C23 is a GCC extension",
+ "%<#%s%> before C23 is a GCC extension",
pfile->directive->name);
}
pfile->state.skipping = 1;
@@ -2685,11 +2690,13 @@ do_elif (cpp_reader *pfile)
{
if (CPP_OPTION (pfile, cplusplus))
cpp_pedwarning (pfile, CPP_W_CXX23_EXTENSIONS,
- "#%s before C++23 is a GCC extension",
+ "%<#%s%> before C++23 is a GCC "
+ "extension",
pfile->directive->name);
else
cpp_pedwarning (pfile, CPP_W_PEDANTIC,
- "#%s before C23 is a GCC extension",
+ "%<#%s%> before C23 is a GCC "
+ "extension",
pfile->directive->name);
}
pfile->state.skipping = skip;
@@ -2725,7 +2732,7 @@ do_endif (cpp_reader *pfile)
struct if_stack *ifs = buffer->if_stack;
if (ifs == NULL)
- cpp_error (pfile, CPP_DL_ERROR, "#endif without #if");
+ cpp_error (pfile, CPP_DL_ERROR, "%<#endif%> without %<#if%>");
else
{
/* Only check EOL if was not originally skipping. */
@@ -2810,7 +2817,7 @@ parse_answer (cpp_reader *pfile, int type, location_t pred_loc,
return true;
cpp_error_with_line (pfile, CPP_DL_ERROR, pred_loc, 0,
- "missing '(' after predicate");
+ "missing %<(%> after predicate");
return false;
}
@@ -2828,7 +2835,7 @@ parse_answer (cpp_reader *pfile, int type, location_t pred_loc,
if (token->type == CPP_EOF)
{
- cpp_error (pfile, CPP_DL_ERROR, "missing ')' to complete answer");
+ cpp_error (pfile, CPP_DL_ERROR, "missing %<)%> to complete answer");
return false;
}
@@ -2840,7 +2847,7 @@ parse_answer (cpp_reader *pfile, int type, location_t pred_loc,
if (!count)
{
- cpp_error (pfile, CPP_DL_ERROR, "predicate's answer is empty");
+ cpp_error (pfile, CPP_DL_ERROR, "predicate%'s answer is empty");
return false;
}
@@ -2955,7 +2962,7 @@ do_assert (cpp_reader *pfile)
is not a duplicate. */
if (*find_answer (node, answer))
{
- cpp_error (pfile, CPP_DL_WARNING, "\"%s\" re-asserted",
+ cpp_error (pfile, CPP_DL_WARNING, "%qs re-asserted",
NODE_NAME (node) + 1);
return;
}
@@ -3038,10 +3045,10 @@ cpp_define (cpp_reader *pfile, const char *str)
void
cpp_define_unused (cpp_reader *pfile, const char *str)
{
- unsigned char warn_unused_macros = CPP_OPTION (pfile, warn_unused_macros);
- CPP_OPTION (pfile, warn_unused_macros) = 0;
- cpp_define (pfile, str);
- CPP_OPTION (pfile, warn_unused_macros) = warn_unused_macros;
+ unsigned char warn_unused_macros = CPP_OPTION (pfile, warn_unused_macros);
+ CPP_OPTION (pfile, warn_unused_macros) = 0;
+ cpp_define (pfile, str);
+ CPP_OPTION (pfile, warn_unused_macros) = warn_unused_macros;
}
/* Use to build macros to be run through cpp_define() as
diff --git a/libcpp/errors.cc b/libcpp/errors.cc
index 295496d..5d8ceb9 100644
--- a/libcpp/errors.cc
+++ b/libcpp/errors.cc
@@ -54,7 +54,7 @@ cpp_diagnostic_get_current_location (cpp_reader *pfile)
/* Print a diagnostic at the given location. */
-ATTRIBUTE_FPTR_PRINTF(5,0)
+ATTRIBUTE_CPP_PPDIAG (5, 0)
static bool
cpp_diagnostic_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
enum cpp_warning_reason reason, rich_location *richloc,
@@ -71,7 +71,7 @@ cpp_diagnostic_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
/* Print a diagnostic at the location of the previously lexed token. */
-ATTRIBUTE_FPTR_PRINTF(4,0)
+ATTRIBUTE_CPP_PPDIAG (4, 0)
static bool
cpp_diagnostic (cpp_reader * pfile, enum cpp_diagnostic_level level,
enum cpp_warning_reason reason,
@@ -190,7 +190,7 @@ cpp_pedwarning_at (cpp_reader * pfile, enum cpp_warning_reason reason,
/* Print a diagnostic at a specific location. */
-ATTRIBUTE_FPTR_PRINTF(6,0)
+ATTRIBUTE_CPP_PPDIAG (6, 0)
static bool
cpp_diagnostic_with_line (cpp_reader * pfile, enum cpp_diagnostic_level level,
enum cpp_warning_reason reason,
diff --git a/libcpp/expr.cc b/libcpp/expr.cc
index 089bf3e..b7772c9 100644
--- a/libcpp/expr.cc
+++ b/libcpp/expr.cc
@@ -678,10 +678,12 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
{
if (radix == 2)
SYNTAX_ERROR2_AT (virtual_location,
- "invalid digit \"%c\" in binary constant", '0' + max_digit);
+ "invalid digit %<%c%> in binary constant",
+ '0' + max_digit);
else
SYNTAX_ERROR2_AT (virtual_location,
- "invalid digit \"%c\" in octal constant", '0' + max_digit);
+ "invalid digit %<%c%> in octal constant",
+ '0' + max_digit);
}
if (float_flag != NOT_FLOAT)
@@ -689,7 +691,7 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
if (radix == 2)
{
cpp_error_with_line (pfile, CPP_DL_ERROR, virtual_location, 0,
- "invalid prefix \"0b\" for floating constant");
+ "invalid prefix %<0b%> for floating constant");
return CPP_N_INVALID;
}
@@ -751,8 +753,8 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
else
{
cpp_error_with_line (pfile, CPP_DL_ERROR, virtual_location, 0,
- "invalid suffix \"%.*s\" on floating constant",
- (int) (limit - str), str);
+ "invalid suffix %<%.*s%> on floating "
+ "constant", (int) (limit - str), str);
return CPP_N_INVALID;
}
}
@@ -762,7 +764,7 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
&& CPP_WTRADITIONAL (pfile)
&& ! cpp_sys_macro_p (pfile))
cpp_warning_with_line (pfile, CPP_W_TRADITIONAL, virtual_location, 0,
- "traditional C rejects the \"%.*s\" suffix",
+ "traditional C rejects the %<%.*s%> suffix",
(int) (limit - str), str);
/* A suffix for double is a GCC extension via decimal float support.
@@ -777,8 +779,8 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
if ((result & CPP_N_DFLOAT) && radix != 10)
{
cpp_error_with_line (pfile, CPP_DL_ERROR, virtual_location, 0,
- "invalid suffix \"%.*s\" with hexadecimal floating constant",
- (int) (limit - str), str);
+ "invalid suffix %<%.*s%> with hexadecimal "
+ "floating constant", (int) (limit - str), str);
return CPP_N_INVALID;
}
@@ -791,11 +793,12 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
if (!CPP_OPTION (pfile, dfp_constants))
cpp_pedwarning_with_line
(pfile, CPP_W_PEDANTIC, virtual_location, 0,
- "decimal float constants are a C23 feature");
+ "decimal floating constants are a C23 feature");
else if (CPP_OPTION (pfile, cpp_warn_c11_c23_compat) > 0)
cpp_warning_with_line (pfile, CPP_W_C11_C23_COMPAT,
virtual_location, 0,
- "decimal float constants are a C23 feature");
+ "decimal floating constants are a C23 "
+ "feature");
}
result |= CPP_N_FLOATING;
@@ -814,8 +817,8 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
else
{
cpp_error_with_line (pfile, CPP_DL_ERROR, virtual_location, 0,
- "invalid suffix \"%.*s\" on integer constant",
- (int) (limit - str), str);
+ "invalid suffix %<%.*s%> on integer "
+ "constant", (int) (limit - str), str);
return CPP_N_INVALID;
}
}
@@ -831,7 +834,7 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
if (u_or_i || large)
cpp_warning_with_line (pfile, large ? CPP_W_LONG_LONG : CPP_W_TRADITIONAL,
virtual_location, 0,
- "traditional C rejects the \"%.*s\" suffix",
+ "traditional C rejects the %<%.*s%> suffix",
(int) (limit - str), str);
}
@@ -853,9 +856,10 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
if ((result & CPP_N_SIZE_T) == CPP_N_SIZE_T
&& !CPP_OPTION (pfile, size_t_literals))
{
- const char *message = (result & CPP_N_UNSIGNED) == CPP_N_UNSIGNED
- ? N_("use of C++23 %<size_t%> integer constant")
- : N_("use of C++23 %<make_signed_t<size_t>%> integer constant");
+ const char *message
+ = (result & CPP_N_UNSIGNED) == CPP_N_UNSIGNED
+ ? N_("use of C++23 %<size_t%> integer constant")
+ : N_("use of C++23 %<make_signed_t<size_t>%> integer constant");
cpp_warning_with_line (pfile, CPP_W_SIZE_T_LITERALS,
virtual_location, 0, message);
}
@@ -1118,7 +1122,7 @@ parse_defined (cpp_reader *pfile)
cpp_context *initial_context = pfile->context;
if (pfile->state.in_directive == 3)
- cpp_error (pfile, CPP_DL_ERROR, "'defined' in #embed parameter");
+ cpp_error (pfile, CPP_DL_ERROR, "%<defined%> in %<#embed%> parameter");
/* Don't expand macros. */
pfile->state.prevent_expansion++;
@@ -1135,14 +1139,14 @@ parse_defined (cpp_reader *pfile)
node = token->val.node.node;
if (paren && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN)
{
- cpp_error (pfile, CPP_DL_ERROR, "missing ')' after \"defined\"");
+ cpp_error (pfile, CPP_DL_ERROR, "missing %<)%> after %<defined%>");
node = 0;
}
}
else
{
cpp_error (pfile, CPP_DL_ERROR,
- "operator \"defined\" requires an identifier");
+ "operator %<defined%> requires an identifier");
if (token->flags & NAMED_OP)
{
cpp_token op;
@@ -1150,7 +1154,7 @@ parse_defined (cpp_reader *pfile)
op.flags = 0;
op.type = token->type;
cpp_error (pfile, CPP_DL_ERROR,
- "(\"%s\" is an alternative token for \"%s\" in C++)",
+ "(%qs is an alternative token for %qs in C++)",
cpp_token_as_text (pfile, token),
cpp_token_as_text (pfile, &op));
}
@@ -1163,7 +1167,7 @@ parse_defined (cpp_reader *pfile)
|| initial_context != &pfile->base_context)
&& CPP_OPTION (pfile, warn_expansion_to_defined))
cpp_pedwarning (pfile, CPP_W_EXPANSION_TO_DEFINED,
- "this use of \"defined\" may not be portable");
+ "this use of %<defined%> may not be portable");
is_defined = _cpp_defined_macro_p (node);
if (!_cpp_maybe_notify_macro_use (pfile, node, token->src_loc))
/* It wasn't a macro after all. */
@@ -1268,7 +1272,7 @@ eval_token (cpp_reader *pfile, const cpp_token *token,
result.low = 0;
if (CPP_OPTION (pfile, warn_undef) && !pfile->state.skip_eval)
cpp_warning_with_line (pfile, CPP_W_UNDEF, virtual_location, 0,
- "\"%s\" is not defined, evaluates to 0",
+ "%qs is not defined, evaluates to %<0%>",
NODE_NAME (token->val.node.node));
}
break;
@@ -1431,7 +1435,7 @@ _cpp_parse_expr (cpp_reader *pfile, const char *dir,
case CPP_HASH:
if (!want_value)
SYNTAX_ERROR2_AT (op.loc,
- "missing binary operator before token \"%s\"",
+ "missing binary operator before token %qs",
cpp_token_as_text (pfile, op.token));
want_value = false;
top->value = eval_token (pfile, op.token, op.loc);
@@ -1456,7 +1460,8 @@ _cpp_parse_expr (cpp_reader *pfile, const char *dir,
default:
if ((int) op.op <= (int) CPP_EQ || (int) op.op >= (int) CPP_PLUS_EQ)
SYNTAX_ERROR2_AT (op.loc,
- "token \"%s\" is not valid in preprocessor expressions",
+ "token %qs is not valid in preprocessor "
+ "expressions",
cpp_token_as_text (pfile, op.token));
break;
}
@@ -1466,7 +1471,7 @@ _cpp_parse_expr (cpp_reader *pfile, const char *dir,
{
if (!want_value)
SYNTAX_ERROR2_AT (op.loc,
- "missing binary operator before token \"%s\"",
+ "missing binary operator before token %qs",
cpp_token_as_text (pfile, op.token));
}
else if (want_value)
@@ -1475,7 +1480,7 @@ _cpp_parse_expr (cpp_reader *pfile, const char *dir,
Try to emit a specific diagnostic. */
if (op.op == CPP_CLOSE_PAREN && top->op == CPP_OPEN_PAREN)
SYNTAX_ERROR_AT (op.loc,
- "missing expression between '(' and ')'");
+ "missing expression between %<(%> and %<)%>");
if (op.op == CPP_EOF && top->op == CPP_EOF)
SYNTAX_ERROR2_AT (op.loc,
@@ -1483,13 +1488,13 @@ _cpp_parse_expr (cpp_reader *pfile, const char *dir,
if (top->op != CPP_EOF && top->op != CPP_OPEN_PAREN)
SYNTAX_ERROR2_AT (op.loc,
- "operator '%s' has no right operand",
+ "operator %qs has no right operand",
cpp_token_as_text (pfile, top->token));
else if (op.op == CPP_CLOSE_PAREN || op.op == CPP_EOF)
/* Complain about missing paren during reduction. */;
else
SYNTAX_ERROR2_AT (op.loc,
- "operator '%s' has no left operand",
+ "operator %qs has no left operand",
cpp_token_as_text (pfile, op.token));
}
@@ -1518,7 +1523,7 @@ _cpp_parse_expr (cpp_reader *pfile, const char *dir,
case CPP_COLON:
if (top->op != CPP_QUERY)
SYNTAX_ERROR_AT (op.loc,
- " ':' without preceding '?'");
+ " %<:%> without preceding %<?%>");
if (!num_zerop (top[-1].value)) /* Was '?' condition true? */
pfile->state.skip_eval++;
else
@@ -1687,7 +1692,7 @@ reduce (cpp_reader *pfile, struct op *top, enum cpp_ttype op)
{
cpp_error_with_line (pfile, CPP_DL_ERROR,
top->token->src_loc,
- 0, "missing ')' in expression");
+ 0, "missing %<)%> in expression");
return 0;
}
top--;
@@ -1716,7 +1721,7 @@ reduce (cpp_reader *pfile, struct op *top, enum cpp_ttype op)
/* COMMA and COLON should not reduce a QUERY operator. */
if (op == CPP_COMMA || op == CPP_COLON)
return top;
- cpp_error (pfile, CPP_DL_ERROR, "'?' without following ':'");
+ cpp_error (pfile, CPP_DL_ERROR, "%<?%> without following %<:%>");
return 0;
default:
@@ -1731,7 +1736,7 @@ reduce (cpp_reader *pfile, struct op *top, enum cpp_ttype op)
if (op == CPP_CLOSE_PAREN)
{
- cpp_error (pfile, CPP_DL_ERROR, "missing '(' in expression");
+ cpp_error (pfile, CPP_DL_ERROR, "missing %<(%> in expression");
return 0;
}
@@ -1763,12 +1768,12 @@ check_promotion (cpp_reader *pfile, const struct op *op)
{
if (!num_positive (op[-1].value, CPP_OPTION (pfile, precision)))
cpp_error_with_line (pfile, CPP_DL_WARNING, op[-1].loc, 0,
- "the left operand of \"%s\" changes sign when promoted",
- cpp_token_as_text (pfile, op->token));
+ "the left operand of %qs changes sign when "
+ "promoted", cpp_token_as_text (pfile, op->token));
}
else if (!num_positive (op->value, CPP_OPTION (pfile, precision)))
cpp_error_with_line (pfile, CPP_DL_WARNING, op->loc, 0,
- "the right operand of \"%s\" changes sign when promoted",
+ "the right operand of %qs changes sign when promoted",
cpp_token_as_text (pfile, op->token));
}
diff --git a/libcpp/files.cc b/libcpp/files.cc
index 5f9fbc5..8f9a5a4 100644
--- a/libcpp/files.cc
+++ b/libcpp/files.cc
@@ -530,7 +530,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
/* Ensure we get no confusion between cached files and directories. */
if (start_dir == NULL)
- cpp_error_at (pfile, CPP_DL_ICE, loc, "NULL directory in find_file");
+ cpp_error_at (pfile, CPP_DL_ICE, loc, "NULL directory in %<find_file%>");
void **hash_slot
= htab_find_slot_with_hash (pfile->file_hash, fname,
@@ -607,7 +607,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
" but they were invalid");
if (!cpp_get_options (pfile)->warn_invalid_pch)
cpp_error (pfile, CPP_DL_NOTE,
- "use -Winvalid-pch for more information");
+ "use %<-Winvalid-pch%> for more information");
}
if (kind == _cpp_FFK_PRE_INCLUDE)
@@ -1415,7 +1415,8 @@ finish_base64_embed (cpp_reader *pfile, const char *fname, bool angle,
{
if (!params->has_embed)
cpp_error_at (pfile, CPP_DL_ERROR, params->loc,
- "'gnu::base64' parameter can be only used with \".\"");
+ "%<gnu::base64%> parameter can be only used with "
+ "%<\".\"%>");
return 0;
}
tokenrun *cur_run = &params->base64.base_run;
@@ -1431,7 +1432,7 @@ finish_base64_embed (cpp_reader *pfile, const char *fname, bool angle,
{
fail:
cpp_error_at (pfile, CPP_DL_ERROR, params->loc,
- "'gnu::base64' argument not valid base64 "
+ "%<gnu::base64%> argument not valid base64 "
"encoded string");
free (buf);
return 0;
@@ -2265,11 +2266,11 @@ _cpp_pop_file_buffer (cpp_reader *pfile, _cpp_file *file,
if (pfile->cb.get_suggestion (pfile, mi_cmacro, names)
&& cpp_warning_with_line (pfile, CPP_W_HEADER_GUARD,
pfile->mi_loc, 0,
- "header guard \"%s\" followed by "
- "\"#define\" of a different macro",
+ "header guard %qs followed by "
+ "%<#define%> of a different macro",
mi_cmacro))
cpp_error_at (pfile, CPP_DL_NOTE, pfile->mi_def_loc,
- "\"%s\" is defined here; did you mean \"%s\"?",
+ "%qs is defined here; did you mean %qs?",
mi_def_cmacro, mi_cmacro);
}
}
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index bff6601..e64c2b6 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -653,6 +653,13 @@ struct cpp_options
cpp_main_search main_search : 8;
};
+#if GCC_VERSION >= 3005
+#define ATTRIBUTE_CPP_PPDIAG(m, n) \
+ __attribute__ ((__format__ (__gcc_diag__, m , n))) ATTRIBUTE_NONNULL(m)
+#else
+#define ATTRIBUTE_CPP_PPDIAG(m, n) ATTRIBUTE_NONNULL(m)
+#endif
+
/* Diagnostic levels. To get a diagnostic without associating a
position in the translation unit with it, use cpp_error_with_line
with a line number of zero. */
@@ -760,7 +767,7 @@ struct cpp_callbacks
enum cpp_warning_reason,
rich_location *,
const char *, va_list *)
- ATTRIBUTE_FPTR_PRINTF(5,0);
+ ATTRIBUTE_CPP_PPDIAG (5,0);
/* Callbacks for when a macro is expanded, or tested (whether
defined or not at the time) in #ifdef, #ifndef or "defined". */
@@ -1357,24 +1364,24 @@ cpp_num cpp_num_sign_extend (cpp_num, size_t);
/* Output a diagnostic of some kind. */
extern bool cpp_error (cpp_reader *, enum cpp_diagnostic_level,
const char *msgid, ...)
- ATTRIBUTE_PRINTF_3;
+ ATTRIBUTE_CPP_PPDIAG (3, 4);
extern bool cpp_warning (cpp_reader *, enum cpp_warning_reason,
const char *msgid, ...)
- ATTRIBUTE_PRINTF_3;
+ ATTRIBUTE_CPP_PPDIAG (3, 4);
extern bool cpp_pedwarning (cpp_reader *, enum cpp_warning_reason,
const char *msgid, ...)
- ATTRIBUTE_PRINTF_3;
+ ATTRIBUTE_CPP_PPDIAG (3, 4);
extern bool cpp_warning_syshdr (cpp_reader *, enum cpp_warning_reason reason,
const char *msgid, ...)
- ATTRIBUTE_PRINTF_3;
+ ATTRIBUTE_CPP_PPDIAG (3, 4);
/* As their counterparts above, but use RICHLOC. */
extern bool cpp_warning_at (cpp_reader *, enum cpp_warning_reason,
rich_location *richloc, const char *msgid, ...)
- ATTRIBUTE_PRINTF_4;
+ ATTRIBUTE_CPP_PPDIAG (4, 5);
extern bool cpp_pedwarning_at (cpp_reader *, enum cpp_warning_reason,
rich_location *richloc, const char *msgid, ...)
- ATTRIBUTE_PRINTF_4;
+ ATTRIBUTE_CPP_PPDIAG (4, 5);
/* Output a diagnostic with "MSGID: " preceding the
error string of errno. No location is printed. */
@@ -1391,27 +1398,27 @@ extern bool cpp_errno_filename (cpp_reader *, enum cpp_diagnostic_level,
extern bool cpp_error_with_line (cpp_reader *, enum cpp_diagnostic_level,
location_t, unsigned,
const char *msgid, ...)
- ATTRIBUTE_PRINTF_5;
+ ATTRIBUTE_CPP_PPDIAG (5, 6);
extern bool cpp_warning_with_line (cpp_reader *, enum cpp_warning_reason,
location_t, unsigned,
const char *msgid, ...)
- ATTRIBUTE_PRINTF_5;
+ ATTRIBUTE_CPP_PPDIAG (5, 6);
extern bool cpp_pedwarning_with_line (cpp_reader *, enum cpp_warning_reason,
location_t, unsigned,
const char *msgid, ...)
- ATTRIBUTE_PRINTF_5;
+ ATTRIBUTE_CPP_PPDIAG (5, 6);
extern bool cpp_warning_with_line_syshdr (cpp_reader *, enum cpp_warning_reason,
location_t, unsigned,
const char *msgid, ...)
- ATTRIBUTE_PRINTF_5;
+ ATTRIBUTE_CPP_PPDIAG (5, 6);
extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
location_t src_loc, const char *msgid, ...)
- ATTRIBUTE_PRINTF_4;
+ ATTRIBUTE_CPP_PPDIAG (4, 5);
extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
rich_location *richloc, const char *msgid, ...)
- ATTRIBUTE_PRINTF_4;
+ ATTRIBUTE_CPP_PPDIAG (4, 5);
/* In lex.cc */
extern int cpp_ideq (const cpp_token *, const char *);
diff --git a/libcpp/init.cc b/libcpp/init.cc
index 3e4a2bc..1cc62a4 100644
--- a/libcpp/init.cc
+++ b/libcpp/init.cc
@@ -663,7 +663,7 @@ static void sanity_checks (cpp_reader *pfile)
type precisions made by cpplib. */
test--;
if (test < 1)
- cpp_error (pfile, CPP_DL_ICE, "cppchar_t must be an unsigned type");
+ cpp_error (pfile, CPP_DL_ICE, "%<cppchar_t%> must be an unsigned type");
if (CPP_OPTION (pfile, precision) > max_precision)
cpp_error (pfile, CPP_DL_ICE,
@@ -674,18 +674,19 @@ static void sanity_checks (cpp_reader *pfile)
if (CPP_OPTION (pfile, precision) < CPP_OPTION (pfile, int_precision))
cpp_error (pfile, CPP_DL_ICE,
- "CPP arithmetic must be at least as precise as a target int");
+ "CPP arithmetic must be at least as precise as a target "
+ "%<int%>");
if (CPP_OPTION (pfile, char_precision) < 8)
- cpp_error (pfile, CPP_DL_ICE, "target char is less than 8 bits wide");
+ cpp_error (pfile, CPP_DL_ICE, "target %<char%> is less than 8 bits wide");
if (CPP_OPTION (pfile, wchar_precision) < CPP_OPTION (pfile, char_precision))
cpp_error (pfile, CPP_DL_ICE,
- "target wchar_t is narrower than target char");
+ "target %<wchar_t%> is narrower than target %<char%>");
if (CPP_OPTION (pfile, int_precision) < CPP_OPTION (pfile, char_precision))
cpp_error (pfile, CPP_DL_ICE,
- "target int is narrower than target char");
+ "target %<int%> is narrower than target %<char%>");
/* This is assumed in eval_token() and could be fixed if necessary. */
if (sizeof (cppchar_t) > sizeof (cpp_num_part))
diff --git a/libcpp/lex.cc b/libcpp/lex.cc
index 4025e5c..66ff6ce 100644
--- a/libcpp/lex.cc
+++ b/libcpp/lex.cc
@@ -1036,7 +1036,7 @@ _cpp_process_line_notes (cpp_reader *pfile, int in_comment)
if (CPP_OPTION (pfile, trigraphs))
cpp_warning_with_line (pfile, CPP_W_TRIGRAPHS,
pfile->line_table->highest_line, col,
- "trigraph ??%c converted to %c",
+ "trigraph %<??%c%> converted to %<%c%>",
note->type,
(int) _cpp_trigraph_map[note->type]);
else
@@ -1044,7 +1044,7 @@ _cpp_process_line_notes (cpp_reader *pfile, int in_comment)
cpp_warning_with_line
(pfile, CPP_W_TRIGRAPHS,
pfile->line_table->highest_line, col,
- "trigraph ??%c ignored, use -trigraphs to enable",
+ "trigraph %<??%c%> ignored, use %<-trigraphs%> to enable",
note->type);
}
}
@@ -1577,7 +1577,7 @@ maybe_warn_bidi_on_char (cpp_reader *pfile, bidi::kind kind,
rich_loc.add_range (bidi::current_ctx_loc ());
cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
"UTF-8 vs UCN mismatch when closing "
- "a context by \"%s\"", bidi::to_str (kind));
+ "a context by %qs", bidi::to_str (kind));
}
}
else if (warn_bidi & bidirectional_any
@@ -1585,11 +1585,11 @@ maybe_warn_bidi_on_char (cpp_reader *pfile, bidi::kind kind,
{
if (kind == bidi::kind::PDF || kind == bidi::kind::PDI)
cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
- "\"%s\" is closing an unopened context",
+ "%qs is closing an unopened context",
bidi::to_str (kind));
else
cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
- "found problematic Unicode character \"%s\"",
+ "found problematic Unicode character %qs",
bidi::to_str (kind));
}
}
@@ -1619,13 +1619,13 @@ _cpp_warn_invalid_utf8 (cpp_reader *pfile)
cpp_error_with_line (pfile, CPP_DL_PEDWARN,
pfile->line_table->highest_line,
CPP_BUF_COL (buffer),
- "invalid UTF-8 character <%x>",
+ "invalid UTF-8 character %<<%x>%>",
cur[0]);
else
cpp_warning_with_line (pfile, CPP_W_INVALID_UTF8,
pfile->line_table->highest_line,
CPP_BUF_COL (buffer),
- "invalid UTF-8 character <%x>",
+ "invalid UTF-8 character %<<%x>%>",
cur[0]);
return cur + 1;
}
@@ -1635,13 +1635,13 @@ _cpp_warn_invalid_utf8 (cpp_reader *pfile)
cpp_error_with_line (pfile, CPP_DL_PEDWARN,
pfile->line_table->highest_line,
CPP_BUF_COL (buffer),
- "invalid UTF-8 character <%x><%x>",
+ "invalid UTF-8 character %<<%x><%x>%>",
cur[0], cur[1]);
else
cpp_warning_with_line (pfile, CPP_W_INVALID_UTF8,
pfile->line_table->highest_line,
CPP_BUF_COL (buffer),
- "invalid UTF-8 character <%x><%x>",
+ "invalid UTF-8 character %<<%x><%x>%>",
cur[0], cur[1]);
return cur + 2;
}
@@ -1651,13 +1651,13 @@ _cpp_warn_invalid_utf8 (cpp_reader *pfile)
cpp_error_with_line (pfile, CPP_DL_PEDWARN,
pfile->line_table->highest_line,
CPP_BUF_COL (buffer),
- "invalid UTF-8 character <%x><%x><%x>",
+ "invalid UTF-8 character %<<%x><%x><%x>%>",
cur[0], cur[1], cur[2]);
else
cpp_warning_with_line (pfile, CPP_W_INVALID_UTF8,
pfile->line_table->highest_line,
CPP_BUF_COL (buffer),
- "invalid UTF-8 character <%x><%x><%x>",
+ "invalid UTF-8 character %<<%x><%x><%x>%>",
cur[0], cur[1], cur[2]);
return cur + 3;
}
@@ -1667,13 +1667,13 @@ _cpp_warn_invalid_utf8 (cpp_reader *pfile)
cpp_error_with_line (pfile, CPP_DL_PEDWARN,
pfile->line_table->highest_line,
CPP_BUF_COL (buffer),
- "invalid UTF-8 character <%x><%x><%x><%x>",
+ "invalid UTF-8 character %<<%x><%x><%x><%x>%>",
cur[0], cur[1], cur[2], cur[3]);
else
cpp_warning_with_line (pfile, CPP_W_INVALID_UTF8,
pfile->line_table->highest_line,
CPP_BUF_COL (buffer),
- "invalid UTF-8 character <%x><%x><%x><%x>",
+ "invalid UTF-8 character %<<%x><%x><%x><%x>%>",
cur[0], cur[1], cur[2], cur[3]);
return cur + 4;
}
@@ -1755,7 +1755,7 @@ _cpp_skip_block_comment (cpp_reader *pfile)
cpp_warning_with_line (pfile, CPP_W_COMMENTS,
pfile->line_table->highest_line,
CPP_BUF_COL (buffer),
- "\"/*\" within comment");
+ "%</*%> within comment");
}
}
else if (c == '\n')
@@ -1933,13 +1933,13 @@ warn_about_normalization (cpp_reader *pfile,
sz = cpp_spell_token (pfile, token, buf, false) - buf;
if (NORMALIZE_STATE_RESULT (s) == normalized_C)
cpp_warning_at (pfile, CPP_W_NORMALIZE, &rich_loc,
- "`%.*s' is not in NFKC", (int) sz, buf);
+ "%<%.*s%> is not in NFKC", (int) sz, buf);
else if (identifier && CPP_OPTION (pfile, xid_identifiers))
cpp_pedwarning_at (pfile, CPP_W_NORMALIZE, &rich_loc,
- "`%.*s' is not in NFC", (int) sz, buf);
+ "%<%.*s%> is not in NFC", (int) sz, buf);
else
cpp_warning_at (pfile, CPP_W_NORMALIZE, &rich_loc,
- "`%.*s' is not in NFC", (int) sz, buf);
+ "%<%.*s%> is not in NFC", (int) sz, buf);
free (buf);
}
}
@@ -1966,7 +1966,7 @@ forms_identifier_p (cpp_reader *pfile, int first,
if (CPP_OPTION (pfile, warn_dollars) && !pfile->state.skipping)
{
CPP_OPTION (pfile, warn_dollars) = 0;
- cpp_error (pfile, CPP_DL_PEDWARN, "'$' in identifier or number");
+ cpp_error (pfile, CPP_DL_PEDWARN, "%<$%> in identifier or number");
}
return true;
@@ -2028,10 +2028,10 @@ maybe_va_opt_error (cpp_reader *pfile)
{
if (CPP_OPTION (pfile, cplusplus))
cpp_pedwarning (pfile, CPP_W_CXX20_EXTENSIONS,
- "__VA_OPT__ is not available until C++20");
+ "%<__VA_OPT__%> is not available until C++20");
else
cpp_pedwarning (pfile, CPP_W_PEDANTIC,
- "__VA_OPT__ is not available until C23");
+ "%<__VA_OPT__%> is not available until C23");
}
}
else if (!pfile->state.va_args_ok)
@@ -2039,7 +2039,7 @@ maybe_va_opt_error (cpp_reader *pfile)
/* __VA_OPT__ should only appear in the replacement list of a
variadic macro. */
cpp_error (pfile, CPP_DL_PEDWARN,
- "__VA_OPT__ can only appear in the expansion"
+ "%<__VA_OPT__%> can only appear in the expansion"
" of a C++20 variadic macro");
}
}
@@ -2056,7 +2056,7 @@ identifier_diagnostics_on_lex (cpp_reader *pfile, cpp_hashnode *node)
/* It is allowed to poison the same identifier twice. */
if ((node->flags & NODE_POISONED) && !pfile->state.poisoned_ok)
{
- cpp_error (pfile, CPP_DL_ERROR, "attempt to use poisoned \"%s\"",
+ cpp_error (pfile, CPP_DL_ERROR, "attempt to use poisoned %qs",
NODE_NAME (node));
const auto data = (cpp_hashnode_extra *)
ht_lookup (pfile->extra_hash_table, node->ident, HT_NO_INSERT);
@@ -2071,11 +2071,11 @@ identifier_diagnostics_on_lex (cpp_reader *pfile, cpp_hashnode *node)
{
if (CPP_OPTION (pfile, cplusplus))
cpp_error (pfile, CPP_DL_PEDWARN,
- "__VA_ARGS__ can only appear in the expansion"
+ "%<__VA_ARGS__%> can only appear in the expansion"
" of a C++11 variadic macro");
else
cpp_error (pfile, CPP_DL_PEDWARN,
- "__VA_ARGS__ can only appear in the expansion"
+ "%<__VA_ARGS__%> can only appear in the expansion"
" of a C99 variadic macro");
}
@@ -2087,7 +2087,7 @@ identifier_diagnostics_on_lex (cpp_reader *pfile, cpp_hashnode *node)
/* For -Wc++-compat, warn about use of C++ named operators. */
if (node->flags & NODE_WARN_OPERATOR)
cpp_warning (pfile, CPP_W_CXX_OPERATOR_NAMES,
- "identifier \"%s\" is a special operator name in C++",
+ "identifier %qs is a special operator name in C++",
NODE_NAME (node));
}
@@ -3485,7 +3485,7 @@ cpp_maybe_module_directive (cpp_reader *pfile, cpp_token *result)
&& _cpp_maybe_notify_macro_use (pfile, node, tok->src_loc)
&& !cpp_fun_like_macro_p (node))
cpp_error_with_line (pfile, CPP_DL_ERROR, tok->src_loc, 0,
- "module control-line \"%s\" cannot be"
+ "module control-line %qs cannot be"
" an object-like macro",
NODE_NAME (node));
}
diff --git a/libcpp/macro.cc b/libcpp/macro.cc
index 2fb3861..f0dfc79 100644
--- a/libcpp/macro.cc
+++ b/libcpp/macro.cc
@@ -141,7 +141,7 @@ class vaopt_state {
if (m_state > 0)
{
cpp_error_at (m_pfile, CPP_DL_ERROR, token->src_loc,
- "__VA_OPT__ may not appear in a __VA_OPT__");
+ "%<__VA_OPT__%> may not appear in a %<__VA_OPT__%>");
return ERROR;
}
++m_state;
@@ -154,7 +154,7 @@ class vaopt_state {
if (token->type != CPP_OPEN_PAREN)
{
cpp_error_at (m_pfile, CPP_DL_ERROR, m_location,
- "__VA_OPT__ must be followed by an "
+ "%<__VA_OPT__%> must be followed by an "
"open parenthesis");
return ERROR;
}
@@ -232,7 +232,7 @@ class vaopt_state {
{
if (m_variadic && m_state != 0)
cpp_error_at (m_pfile, CPP_DL_ERROR, m_location,
- "unterminated __VA_OPT__");
+ "unterminated %<__VA_OPT__%>");
return m_state == 0;
}
@@ -393,7 +393,7 @@ builtin_has_include_1 (cpp_reader *pfile, const char *name, bool *paren,
{
if (!pfile->state.in_directive)
cpp_error (pfile, CPP_DL_ERROR,
- "\"%s\" used outside of preprocessing directive", name);
+ "%qs used outside of preprocessing directive", name);
pfile->state.angled_headers = true;
const auto sav_padding = pfile->state.directive_wants_padding;
@@ -404,7 +404,7 @@ builtin_has_include_1 (cpp_reader *pfile, const char *name, bool *paren,
token = _cpp_get_token_no_padding (pfile);
else
cpp_error (pfile, CPP_DL_ERROR,
- "missing '(' before \"%s\" operand", name);
+ "missing %<(%> before %qs operand", name);
pfile->state.angled_headers = false;
pfile->state.directive_wants_padding = sav_padding;
@@ -422,7 +422,7 @@ builtin_has_include_1 (cpp_reader *pfile, const char *name, bool *paren,
fname = _cpp_bracket_include (pfile);
else
cpp_error (pfile, CPP_DL_ERROR,
- "operator \"%s\" requires a header-name", name);
+ "operator %qs requires a header-name", name);
return fname;
}
@@ -451,7 +451,7 @@ builtin_has_include (cpp_reader *pfile, cpp_hashnode *op, bool has_next)
if (paren
&& _cpp_get_token_no_padding (pfile)->type != CPP_CLOSE_PAREN)
cpp_error (pfile, CPP_DL_ERROR,
- "missing ')' after \"%s\" operand", NODE_NAME (op));
+ "missing %<)%> after %qs operand", NODE_NAME (op));
return result;
}
@@ -496,7 +496,7 @@ builtin_has_embed (cpp_reader *pfile)
if (!*fname)
{
cpp_error_with_line (pfile, CPP_DL_ERROR, params.loc, 0,
- "empty filename in '%s'", "__has_embed");
+ "empty filename in %qs", "__has_embed");
ok = false;
}
@@ -530,7 +530,7 @@ _cpp_warn_if_unused_macro (cpp_reader *pfile, cpp_hashnode *node,
(linemap_lookup (pfile->line_table,
macro->line))))
cpp_warning_with_line (pfile, CPP_W_UNUSED_MACROS, macro->line, 0,
- "macro \"%s\" is not used", NODE_NAME (node));
+ "macro %qs is not used", NODE_NAME (node));
}
return 1;
@@ -569,14 +569,14 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node,
switch (node->value.builtin)
{
default:
- cpp_error (pfile, CPP_DL_ICE, "invalid built-in macro \"%s\"",
+ cpp_error (pfile, CPP_DL_ICE, "invalid built-in macro %qs",
NODE_NAME (node));
break;
case BT_TIMESTAMP:
{
if (CPP_OPTION (pfile, warn_date_time))
- cpp_warning (pfile, CPP_W_DATE_TIME, "macro \"%s\" might prevent "
+ cpp_warning (pfile, CPP_W_DATE_TIME, "macro %qs might prevent "
"reproducible builds", NODE_NAME (node));
cpp_buffer *pbuffer = cpp_get_buffer (pfile);
@@ -684,7 +684,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node,
case BT_DATE:
case BT_TIME:
if (CPP_OPTION (pfile, warn_date_time))
- cpp_warning (pfile, CPP_W_DATE_TIME, "macro \"%s\" might prevent "
+ cpp_warning (pfile, CPP_W_DATE_TIME, "macro %qs might prevent "
"reproducible builds", NODE_NAME (node));
if (pfile->date == NULL)
{
@@ -730,7 +730,8 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node,
case BT_COUNTER:
if (CPP_OPTION (pfile, directives_only) && pfile->state.in_directive)
cpp_error (pfile, CPP_DL_ERROR,
- "__COUNTER__ expanded inside directive with -fdirectives-only");
+ "%<__COUNTER__%> expanded inside directive with "
+ "%<-fdirectives-only%>");
number = pfile->counter++;
break;
@@ -756,7 +757,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node,
if (CPP_OPTION (pfile, traditional))
{
cpp_error (pfile, CPP_DL_ERROR, /* FIXME should be DL_SORRY */
- "'__has_embed' not supported in traditional C");
+ "%<__has_embed%> not supported in traditional C");
break;
}
number = builtin_has_embed (pfile);
@@ -884,7 +885,7 @@ builtin_macro (cpp_reader *pfile, cpp_hashnode *node,
else
_cpp_push_token_context (pfile, NULL, token, 1);
if (pfile->buffer->cur != pfile->buffer->rlimit)
- cpp_error (pfile, CPP_DL_ICE, "invalid built-in macro \"%s\"",
+ cpp_error (pfile, CPP_DL_ICE, "invalid built-in macro %qs",
NODE_NAME (node));
_cpp_pop_buffer (pfile);
@@ -1003,7 +1004,7 @@ stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count)
if (backslash_count & 1)
{
cpp_error (pfile, CPP_DL_WARNING,
- "invalid string literal, ignoring final '\\'");
+ "invalid string literal, ignoring final %<\\%>");
dest--;
}
@@ -1200,26 +1201,26 @@ _cpp_arguments_ok (cpp_reader *pfile, cpp_macro *macro, const cpp_hashnode *node
if (CPP_OPTION (pfile, cplusplus))
cpp_pedwarning (pfile, CPP_W_CXX20_EXTENSIONS,
"ISO C++11 requires at least one argument "
- "for the \"...\" in a variadic macro");
+ "for the %<...%> in a variadic macro");
else
cpp_pedwarning (pfile, CPP_W_PEDANTIC,
"ISO C99 requires at least one argument "
- "for the \"...\" in a variadic macro");
+ "for the %<...%> in a variadic macro");
}
return true;
}
cpp_error (pfile, CPP_DL_ERROR,
- "macro \"%s\" requires %u arguments, but only %u given",
+ "macro %qs requires %u arguments, but only %u given",
NODE_NAME (node), macro->paramc, argc);
}
else
cpp_error (pfile, CPP_DL_ERROR,
- "macro \"%s\" passed %u arguments, but takes just %u",
+ "macro %qs passed %u arguments, but takes just %u",
NODE_NAME (node), argc, macro->paramc);
if (macro->line > RESERVED_LOCATION_COUNT)
- cpp_error_at (pfile, CPP_DL_NOTE, macro->line, "macro \"%s\" defined here",
+ cpp_error_at (pfile, CPP_DL_NOTE, macro->line, "macro %qs defined here",
NODE_NAME (node));
return false;
@@ -1413,7 +1414,7 @@ collect_args (cpp_reader *pfile, const cpp_hashnode *node,
if (token == &pfile->endarg)
_cpp_backup_tokens (pfile, 1);
cpp_error (pfile, CPP_DL_ERROR,
- "unterminated argument list invoking macro \"%s\"",
+ "unterminated argument list invoking macro %qs",
NODE_NAME (node));
}
else
@@ -1559,8 +1560,8 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
{
if (CPP_WTRADITIONAL (pfile) && ! node->value.macro->syshdr)
cpp_warning (pfile, CPP_W_TRADITIONAL,
- "function-like macro \"%s\" must be used with arguments in traditional C",
- NODE_NAME (node));
+ "function-like macro %qs must be used with "
+ "arguments in traditional C", NODE_NAME (node));
if (pragma_buff)
_cpp_release_buff (pfile, pragma_buff);
@@ -3462,7 +3463,7 @@ _cpp_save_parameter (cpp_reader *pfile, unsigned n, cpp_hashnode *node,
/* Constraint 6.10.3.6 - duplicate parameter names. */
if (node->type == NT_MACRO_ARG)
{
- cpp_error (pfile, CPP_DL_ERROR, "duplicate macro parameter \"%s\"",
+ cpp_error (pfile, CPP_DL_ERROR, "duplicate macro parameter %qs",
NODE_NAME (node));
return false;
}
@@ -3544,11 +3545,11 @@ parse_params (cpp_reader *pfile, unsigned *n_ptr, bool *variadic_ptr)
{
const char *const msgs[5] =
{
- N_("expected parameter name, found \"%s\""),
- N_("expected ',' or ')', found \"%s\""),
+ N_("expected parameter name, found %qs"),
+ N_("expected %<,%> or %<)%>, found %qs"),
N_("expected parameter name before end of line"),
- N_("expected ')' before end of line"),
- N_("expected ')' after \"...\"")
+ N_("expected %<)%> before end of line"),
+ N_("expected %<)%> after %<...%>")
};
unsigned ix = prev_ident;
const unsigned char *as_text = NULL;
@@ -3663,7 +3664,7 @@ create_iso_definition (cpp_reader *pfile)
{
bool following_paste_op = false;
const char *paste_op_error_msg =
- N_("'##' cannot appear at either end of a macro expansion");
+ N_("%<##%> cannot appear at either end of a macro expansion");
unsigned int num_extra_tokens = 0;
unsigned nparms = 0;
cpp_hashnode **params = NULL;
@@ -3779,7 +3780,7 @@ create_iso_definition (cpp_reader *pfile)
else if (CPP_OPTION (pfile, lang) != CLK_ASM)
{
cpp_error (pfile, CPP_DL_ERROR,
- "'#' is not followed by a macro parameter");
+ "%<#%> is not followed by a macro parameter");
goto out;
}
}
@@ -3940,15 +3941,14 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node,
= (cpp_builtin_macro_p (node) && !(node->flags & NODE_WARN))
? CPP_W_BUILTIN_MACRO_REDEFINED : CPP_W_NONE;
- bool warned =
- cpp_pedwarning_with_line (pfile, reason,
- macro->line, 0,
- "\"%s\" redefined", NODE_NAME (node));
+ bool warned
+ = cpp_pedwarning_with_line (pfile, reason, macro->line, 0,
+ "%qs redefined", NODE_NAME (node));
if (warned && cpp_user_macro_p (node))
- cpp_error_with_line (pfile, CPP_DL_NOTE,
- node->value.macro->line, 0,
- "this is the location of the previous definition");
+ cpp_error_with_line (pfile, CPP_DL_NOTE, node->value.macro->line,
+ 0, "this is the location of the previous "
+ "definition");
}
_cpp_free_definition (node);
}
@@ -4085,8 +4085,8 @@ check_trad_stringification (cpp_reader *pfile, const cpp_macro *macro,
&& !memcmp (p, NODE_NAME (node), len))
{
cpp_warning (pfile, CPP_W_TRADITIONAL,
- "macro argument \"%s\" would be stringified in traditional C",
- NODE_NAME (node));
+ "macro argument %qs would be stringified in "
+ "traditional C", NODE_NAME (node));
break;
}
}
diff --git a/libcpp/pch.cc b/libcpp/pch.cc
index f2f74ed..0989fb3 100644
--- a/libcpp/pch.cc
+++ b/libcpp/pch.cc
@@ -613,7 +613,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
{
if (CPP_OPTION (r, warn_invalid_pch))
cpp_warning_syshdr (r, CPP_W_INVALID_PCH,
- "%s: not used because `%.*s' is poisoned",
+ "%s: not used because %<%.*s%> is poisoned",
name, m.name_length, namebuf);
goto fail;
}
@@ -635,7 +635,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
if (CPP_OPTION (r, warn_invalid_pch))
cpp_warning_syshdr (r, CPP_W_INVALID_PCH,
- "%s: not used because `%.*s' not defined",
+ "%s: not used because %<%.*s%> not defined",
name, m.name_length, namebuf);
goto fail;
}
@@ -647,10 +647,12 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
{
if (CPP_OPTION (r, warn_invalid_pch))
cpp_warning_syshdr (r, CPP_W_INVALID_PCH,
- "%s: not used because `%.*s' defined as `%s' not `%.*s'",
- name, m.name_length, namebuf, newdefn + m.name_length,
- m.definition_length - m.name_length,
- namebuf + m.name_length);
+ "%s: not used because %<%.*s%> defined as "
+ "%<%s%> not %<%.*s%>",
+ name, m.name_length, namebuf,
+ newdefn + m.name_length,
+ m.definition_length - m.name_length,
+ namebuf + m.name_length);
goto fail;
}
}
@@ -688,7 +690,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
{
if (CPP_OPTION (r, warn_invalid_pch))
cpp_warning_syshdr (r, CPP_W_INVALID_PCH,
- "%s: not used because `%s' is defined",
+ "%s: not used because %qs is defined",
name, first);
goto fail;
}
@@ -708,7 +710,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
{
if (CPP_OPTION (r, warn_invalid_pch))
cpp_warning_syshdr (r, CPP_W_INVALID_PCH,
- "%s: not used because `__COUNTER__' is invalid",
+ "%s: not used because %<__COUNTER__%> is invalid",
name);
goto fail;
}
diff --git a/libcpp/traditional.cc b/libcpp/traditional.cc
index cf0ef4c..ac01f9d 100644
--- a/libcpp/traditional.cc
+++ b/libcpp/traditional.cc
@@ -819,7 +819,7 @@ _cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro,
if (lex_state == ls_fun_close)
cpp_error_with_line (pfile, CPP_DL_ERROR, fmacro.line, 0,
- "unterminated argument list invoking macro \"%s\"",
+ "unterminated argument list invoking macro %qs",
NODE_NAME (fmacro.node));
return result;
}
@@ -888,7 +888,7 @@ recursive_macro (cpp_reader *pfile, cpp_hashnode *node)
if (recursing)
cpp_error (pfile, CPP_DL_ERROR,
- "detected recursion whilst expanding macro \"%s\"",
+ "detected recursion whilst expanding macro %qs",
NODE_NAME (node));
return recursing;