Commit c24300ba by David Malcolm Committed by David Malcolm

Cleanup of libcpp diagnostic callbacks

This patch renames the "error" callback within libcpp
to "diagnostic", and uses the pair of enums in cpplib.h, rather
than passing two different kinds of "int" around.

gcc/c-family/ChangeLog:
	* c-common.c (c_option_controlling_cpp_error): Rename to...
	(c_option_controlling_cpp_diagnostic): ...this, and convert
	"reason" from int to enum.
	(c_cpp_error): Rename to...
	(c_cpp_diagnostic): ...this, converting level and reason to enums.
	* c-common.h (c_cpp_error): Rename to...
	(c_cpp_diagnostic): ...this, converting level and reason to enums.
	* c-opts.c (c_common_init_options): Update for renaming.

gcc/fortran/ChangeLog:
	* cpp.c (gfc_cpp_init_0): Update for renamings.
	(cb_cpp_error): Rename to...
	(cb_cpp_diagnostic): ...this, converting level and reason to
	enums.

gcc/ChangeLog:
	* genmatch.c (error_cb): Rename to...
	(diagnostic_cb): ...this, converting int params to enums.
	(fatal_at): Update for renaming.
	(warning_at): Likewise.
	(main): Likewise.
	* input.c (selftest::ebcdic_execution_charset::apply):
	Update for renaming of...
	(selftest::ebcdic_execution_charset::on_error): ...this, renaming
	to...
	(selftest::ebcdic_execution_charset::on_diagnostic): ...this,
	converting level and reason to enums.
	(class selftest::lexer_error_sink): Rename to...
	(class selftest::lexer_test_options): ...this, renaming field
	"m_errors" to "m_diagnostics".
	(selftest::lexer_test_options::apply): Update for renaming of...
	(selftest::lexer_test_options::on_error): ...this, renaming to...
	(selftest::lexer_test_options::on_diagnostic): ...this
	converting level and reason to enums.
	(selftest::test_lexer_string_locations_raw_string_unterminated):
	Update for renamings.
	* opth-gen.awk (struct cpp_reason_option_codes_t): Use enum for
	"reason".

libcpp/ChangeLog:
	* charset.c (noop_error_cb): Rename to...
	(noop_diagnostic_cb): ...this, converting params to enums.
	(cpp_interpret_string_ranges): Update for renaming and enums.
	* directives.c (check_eol_1): Convert reason to enum.
	(do_diagnostic): Convert code and reason to enum.
	(do_error): Use CPP_W_NONE rather than 0.
	(do_pragma_dependency): Likewise.
	* errors.c (cpp_diagnostic_at): Convert level and reason to enums.
	Update for renaming.
	(cpp_diagnostic): Convert level and reason to enums.
	(cpp_error): Convert level to enum.
	(cpp_warning): Convert reason to enums.
	(cpp_pedwarning): Likewise.
	(cpp_warning_syshdr): Likewise.
	(cpp_diagnostic_with_line): Convert level and reason to enums.
	Update for renaming.
	(cpp_error_with_line): Convert level to enum.
	(cpp_warning_with_line): Convert reason to enums.
	(cpp_pedwarning_with_line): Likewise.
	(cpp_warning_with_line_syshdr): Likewise.
	(cpp_error_at): Convert level to enum.
	(cpp_errno): Likewise.
	(cpp_errno_filename): Likewise.
	* include/cpplib.h (enum cpp_diagnostic_level): Name this enum,
	and move to before struct cpp_callbacks.
	(enum cpp_warning_reason): Likewise.
	(cpp_callbacks::diagnostic): Convert params from int to enums.
	(cpp_error): Convert int param to enum cpp_diagnostic_level.
	(cpp_warning): Convert int param to enum cpp_warning_reason.
	(cpp_pedwarning): Likewise.
	(cpp_warning_syshdr): Likewise.
	(cpp_errno): Convert int param to enum cpp_diagnostic_level.
	(cpp_errno_filename): Likewise.
	(cpp_error_with_line): Likewise.
	(cpp_warning_with_line): Convert int param to enum
	cpp_warning_reason.
	(cpp_pedwarning_with_line): Likewise.
	(cpp_warning_with_line_syshdr): Likewise.
	(cpp_error_at): Convert int param to enum cpp_diagnostic_level.
	* macro.c (create_iso_definition): Convert int to enum.
	(_cpp_create_definition): Likewise.

From-SVN: r264999
parent 5abdb369
2018-10-09 David Malcolm <dmalcolm@redhat.com>
* genmatch.c (error_cb): Rename to...
(diagnostic_cb): ...this, converting int params to enums.
(fatal_at): Update for renaming.
(warning_at): Likewise.
(main): Likewise.
* input.c (selftest::ebcdic_execution_charset::apply):
Update for renaming of...
(selftest::ebcdic_execution_charset::on_error): ...this, renaming
to...
(selftest::ebcdic_execution_charset::on_diagnostic): ...this,
converting level and reason to enums.
(class selftest::lexer_error_sink): Rename to...
(class selftest::lexer_test_options): ...this, renaming field
"m_errors" to "m_diagnostics".
(selftest::lexer_test_options::apply): Update for renaming of...
(selftest::lexer_test_options::on_error): ...this, renaming to...
(selftest::lexer_test_options::on_diagnostic): ...this
converting level and reason to enums.
(selftest::test_lexer_string_locations_raw_string_unterminated):
Update for renamings.
* opth-gen.awk (struct cpp_reason_option_codes_t): Use enum for
"reason".
2018-10-09 Paul A. Clarke <pc@us.ibm.com> 2018-10-09 Paul A. Clarke <pc@us.ibm.com>
* config.gcc (powerpc*-*-*): Add pmmintrin.h to extra_headers. * config.gcc (powerpc*-*-*): Add pmmintrin.h to extra_headers.
2018-10-09 David Malcolm <dmalcolm@redhat.com>
* c-common.c (c_option_controlling_cpp_error): Rename to...
(c_option_controlling_cpp_diagnostic): ...this, and convert
"reason" from int to enum.
(c_cpp_error): Rename to...
(c_cpp_diagnostic): ...this, converting level and reason to enums.
* c-common.h (c_cpp_error): Rename to...
(c_cpp_diagnostic): ...this, converting level and reason to enums.
* c-opts.c (c_common_init_options): Update for renaming.
2018-10-08 Richard Sandiford <richard.sandiford@arm.com> 2018-10-08 Richard Sandiford <richard.sandiford@arm.com>
PR c/87286 PR c/87286
......
...@@ -6068,7 +6068,7 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type, ...@@ -6068,7 +6068,7 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type,
message, or 0 if none. */ message, or 0 if none. */
static int static int
c_option_controlling_cpp_error (int reason) c_option_controlling_cpp_diagnostic (enum cpp_warning_reason reason)
{ {
const struct cpp_reason_option_codes_t *entry; const struct cpp_reason_option_codes_t *entry;
...@@ -6080,7 +6080,7 @@ c_option_controlling_cpp_error (int reason) ...@@ -6080,7 +6080,7 @@ c_option_controlling_cpp_error (int reason)
return 0; return 0;
} }
/* Callback from cpp_error for PFILE to print diagnostics from the /* Callback from cpp_diagnostic for PFILE to print diagnostics from the
preprocessor. The diagnostic is of type LEVEL, with REASON set preprocessor. The diagnostic is of type LEVEL, with REASON set
to the reason code if LEVEL is represents a warning, at location to the reason code if LEVEL is represents a warning, at location
RICHLOC unless this is after lexing and the compiler's location RICHLOC unless this is after lexing and the compiler's location
...@@ -6089,7 +6089,9 @@ c_option_controlling_cpp_error (int reason) ...@@ -6089,7 +6089,9 @@ c_option_controlling_cpp_error (int reason)
otherwise. */ otherwise. */
bool bool
c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason, c_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
enum cpp_diagnostic_level level,
enum cpp_warning_reason reason,
rich_location *richloc, rich_location *richloc,
const char *msg, va_list *ap) const char *msg, va_list *ap)
{ {
...@@ -6134,8 +6136,9 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason, ...@@ -6134,8 +6136,9 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
richloc->set_range (0, input_location, SHOW_RANGE_WITH_CARET); richloc->set_range (0, input_location, SHOW_RANGE_WITH_CARET);
diagnostic_set_info_translated (&diagnostic, msg, ap, diagnostic_set_info_translated (&diagnostic, msg, ap,
richloc, dlevel); richloc, dlevel);
diagnostic_override_option_index (&diagnostic, diagnostic_override_option_index
c_option_controlling_cpp_error (reason)); (&diagnostic,
c_option_controlling_cpp_diagnostic (reason));
ret = diagnostic_report_diagnostic (global_dc, &diagnostic); ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
if (level == CPP_DL_WARNING_SYSHDR) if (level == CPP_DL_WARNING_SYSHDR)
global_dc->dc_warn_system_headers = save_warn_system_headers; global_dc->dc_warn_system_headers = save_warn_system_headers;
......
...@@ -1000,7 +1000,8 @@ extern void init_c_lex (void); ...@@ -1000,7 +1000,8 @@ extern void init_c_lex (void);
extern void c_cpp_builtins (cpp_reader *); extern void c_cpp_builtins (cpp_reader *);
extern void c_cpp_builtins_optimize_pragma (cpp_reader *, tree, tree); extern void c_cpp_builtins_optimize_pragma (cpp_reader *, tree, tree);
extern bool c_cpp_error (cpp_reader *, int, int, rich_location *, extern bool c_cpp_diagnostic (cpp_reader *, enum cpp_diagnostic_level,
enum cpp_warning_reason, rich_location *,
const char *, va_list *) const char *, va_list *)
ATTRIBUTE_GCC_DIAG(5,0); ATTRIBUTE_GCC_DIAG(5,0);
extern int c_common_has_attribute (cpp_reader *); extern int c_common_has_attribute (cpp_reader *);
......
...@@ -224,7 +224,7 @@ c_common_init_options (unsigned int decoded_options_count, ...@@ -224,7 +224,7 @@ c_common_init_options (unsigned int decoded_options_count,
parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89, parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
ident_hash, line_table); ident_hash, line_table);
cb = cpp_get_callbacks (parse_in); cb = cpp_get_callbacks (parse_in);
cb->error = c_cpp_error; cb->diagnostic = c_cpp_diagnostic;
cpp_opts = cpp_get_options (parse_in); cpp_opts = cpp_get_options (parse_in);
cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS; cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
......
2018-10-09 David Malcolm <dmalcolm@redhat.com>
* cpp.c (gfc_cpp_init_0): Update for renamings.
(cb_cpp_error): Rename to...
(cb_cpp_diagnostic): ...this, converting level and reason to
enums.
2018-10-09 Tobias Burnus <burnus@net-b.de> 2018-10-09 Tobias Burnus <burnus@net-b.de>
PR fortran/83522 PR fortran/83522
......
...@@ -142,7 +142,8 @@ static void cb_include (cpp_reader *, source_location, const unsigned char *, ...@@ -142,7 +142,8 @@ static void cb_include (cpp_reader *, source_location, const unsigned char *,
static void cb_ident (cpp_reader *, source_location, const cpp_string *); static void cb_ident (cpp_reader *, source_location, const cpp_string *);
static void cb_used_define (cpp_reader *, source_location, cpp_hashnode *); static void cb_used_define (cpp_reader *, source_location, cpp_hashnode *);
static void cb_used_undef (cpp_reader *, source_location, cpp_hashnode *); static void cb_used_undef (cpp_reader *, source_location, cpp_hashnode *);
static bool cb_cpp_error (cpp_reader *, int, int, rich_location *, static bool cb_cpp_diagnostic (cpp_reader *, enum cpp_diagnostic_level,
enum cpp_warning_reason, rich_location *,
const char *, va_list *) const char *, va_list *)
ATTRIBUTE_GCC_DIAG(5,0); ATTRIBUTE_GCC_DIAG(5,0);
void pp_dir_change (cpp_reader *, const char *); void pp_dir_change (cpp_reader *, const char *);
...@@ -504,7 +505,7 @@ gfc_cpp_init_0 (void) ...@@ -504,7 +505,7 @@ gfc_cpp_init_0 (void)
cb->line_change = cb_line_change; cb->line_change = cb_line_change;
cb->ident = cb_ident; cb->ident = cb_ident;
cb->def_pragma = cb_def_pragma; cb->def_pragma = cb_def_pragma;
cb->error = cb_cpp_error; cb->diagnostic = cb_cpp_diagnostic;
if (gfc_cpp_option.dump_includes) if (gfc_cpp_option.dump_includes)
cb->include = cb_include; cb->include = cb_include;
...@@ -1020,7 +1021,9 @@ cb_used_define (cpp_reader *pfile, source_location line ATTRIBUTE_UNUSED, ...@@ -1020,7 +1021,9 @@ cb_used_define (cpp_reader *pfile, source_location line ATTRIBUTE_UNUSED,
Returns true if a diagnostic was emitted, false otherwise. */ Returns true if a diagnostic was emitted, false otherwise. */
static bool static bool
cb_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason, cb_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
enum cpp_diagnostic_level level,
enum cpp_warning_reason reason,
rich_location *richloc, rich_location *richloc,
const char *msg, va_list *ap) const char *msg, va_list *ap)
{ {
......
...@@ -73,7 +73,8 @@ static bool ...@@ -73,7 +73,8 @@ static bool
#if GCC_VERSION >= 4001 #if GCC_VERSION >= 4001
__attribute__((format (printf, 5, 0))) __attribute__((format (printf, 5, 0)))
#endif #endif
error_cb (cpp_reader *, int errtype, int, rich_location *richloc, diagnostic_cb (cpp_reader *, enum cpp_diagnostic_level errtype,
enum cpp_warning_reason, rich_location *richloc,
const char *msg, va_list *ap) const char *msg, va_list *ap)
{ {
const line_map_ordinary *map; const line_map_ordinary *map;
...@@ -122,7 +123,7 @@ fatal_at (const cpp_token *tk, const char *msg, ...) ...@@ -122,7 +123,7 @@ fatal_at (const cpp_token *tk, const char *msg, ...)
rich_location richloc (line_table, tk->src_loc); rich_location richloc (line_table, tk->src_loc);
va_list ap; va_list ap;
va_start (ap, msg); va_start (ap, msg);
error_cb (NULL, CPP_DL_FATAL, 0, &richloc, msg, &ap); diagnostic_cb (NULL, CPP_DL_FATAL, CPP_W_NONE, &richloc, msg, &ap);
va_end (ap); va_end (ap);
} }
...@@ -135,7 +136,7 @@ fatal_at (source_location loc, const char *msg, ...) ...@@ -135,7 +136,7 @@ fatal_at (source_location loc, const char *msg, ...)
rich_location richloc (line_table, loc); rich_location richloc (line_table, loc);
va_list ap; va_list ap;
va_start (ap, msg); va_start (ap, msg);
error_cb (NULL, CPP_DL_FATAL, 0, &richloc, msg, &ap); diagnostic_cb (NULL, CPP_DL_FATAL, CPP_W_NONE, &richloc, msg, &ap);
va_end (ap); va_end (ap);
} }
...@@ -148,7 +149,7 @@ warning_at (const cpp_token *tk, const char *msg, ...) ...@@ -148,7 +149,7 @@ warning_at (const cpp_token *tk, const char *msg, ...)
rich_location richloc (line_table, tk->src_loc); rich_location richloc (line_table, tk->src_loc);
va_list ap; va_list ap;
va_start (ap, msg); va_start (ap, msg);
error_cb (NULL, CPP_DL_WARNING, 0, &richloc, msg, &ap); diagnostic_cb (NULL, CPP_DL_WARNING, CPP_W_NONE, &richloc, msg, &ap);
va_end (ap); va_end (ap);
} }
...@@ -161,7 +162,7 @@ warning_at (source_location loc, const char *msg, ...) ...@@ -161,7 +162,7 @@ warning_at (source_location loc, const char *msg, ...)
rich_location richloc (line_table, loc); rich_location richloc (line_table, loc);
va_list ap; va_list ap;
va_start (ap, msg); va_start (ap, msg);
error_cb (NULL, CPP_DL_WARNING, 0, &richloc, msg, &ap); diagnostic_cb (NULL, CPP_DL_WARNING, CPP_W_NONE, &richloc, msg, &ap);
va_end (ap); va_end (ap);
} }
...@@ -5071,7 +5072,7 @@ main (int argc, char **argv) ...@@ -5071,7 +5072,7 @@ main (int argc, char **argv)
r = cpp_create_reader (CLK_GNUC99, NULL, line_table); r = cpp_create_reader (CLK_GNUC99, NULL, line_table);
cpp_callbacks *cb = cpp_get_callbacks (r); cpp_callbacks *cb = cpp_get_callbacks (r);
cb->error = error_cb; cb->diagnostic = diagnostic_cb;
/* Add the build directory to the #include "" search path. */ /* Add the build directory to the #include "" search path. */
cpp_dir *dir = XCNEW (cpp_dir); cpp_dir *dir = XCNEW (cpp_dir);
......
...@@ -2116,12 +2116,12 @@ class ebcdic_execution_charset : public lexer_test_options ...@@ -2116,12 +2116,12 @@ class ebcdic_execution_charset : public lexer_test_options
cpp_opts->narrow_charset = "IBM1047"; cpp_opts->narrow_charset = "IBM1047";
cpp_callbacks *callbacks = cpp_get_callbacks (test.m_parser); cpp_callbacks *callbacks = cpp_get_callbacks (test.m_parser);
callbacks->error = on_error; callbacks->diagnostic = on_diagnostic;
} }
static bool on_error (cpp_reader *pfile ATTRIBUTE_UNUSED, static bool on_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
int level ATTRIBUTE_UNUSED, enum cpp_diagnostic_level level ATTRIBUTE_UNUSED,
int reason ATTRIBUTE_UNUSED, enum cpp_warning_reason reason ATTRIBUTE_UNUSED,
rich_location *richloc ATTRIBUTE_UNUSED, rich_location *richloc ATTRIBUTE_UNUSED,
const char *msgid, va_list *ap ATTRIBUTE_UNUSED) const char *msgid, va_list *ap ATTRIBUTE_UNUSED)
ATTRIBUTE_FPTR_PRINTF(5,0) ATTRIBUTE_FPTR_PRINTF(5,0)
...@@ -2153,53 +2153,53 @@ class ebcdic_execution_charset : public lexer_test_options ...@@ -2153,53 +2153,53 @@ class ebcdic_execution_charset : public lexer_test_options
ebcdic_execution_charset *ebcdic_execution_charset::s_singleton; ebcdic_execution_charset *ebcdic_execution_charset::s_singleton;
/* A lexer_test_options subclass that records a list of error /* A lexer_test_options subclass that records a list of diagnostic
messages emitted by the lexer. */ messages emitted by the lexer. */
class lexer_error_sink : public lexer_test_options class lexer_diagnostic_sink : public lexer_test_options
{ {
public: public:
lexer_error_sink () lexer_diagnostic_sink ()
{ {
gcc_assert (s_singleton == NULL); gcc_assert (s_singleton == NULL);
s_singleton = this; s_singleton = this;
} }
~lexer_error_sink () ~lexer_diagnostic_sink ()
{ {
gcc_assert (s_singleton == this); gcc_assert (s_singleton == this);
s_singleton = NULL; s_singleton = NULL;
int i; int i;
char *str; char *str;
FOR_EACH_VEC_ELT (m_errors, i, str) FOR_EACH_VEC_ELT (m_diagnostics, i, str)
free (str); free (str);
} }
void apply (lexer_test &test) FINAL OVERRIDE void apply (lexer_test &test) FINAL OVERRIDE
{ {
cpp_callbacks *callbacks = cpp_get_callbacks (test.m_parser); cpp_callbacks *callbacks = cpp_get_callbacks (test.m_parser);
callbacks->error = on_error; callbacks->diagnostic = on_diagnostic;
} }
static bool on_error (cpp_reader *pfile ATTRIBUTE_UNUSED, static bool on_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
int level ATTRIBUTE_UNUSED, enum cpp_diagnostic_level level ATTRIBUTE_UNUSED,
int reason ATTRIBUTE_UNUSED, enum cpp_warning_reason reason ATTRIBUTE_UNUSED,
rich_location *richloc ATTRIBUTE_UNUSED, rich_location *richloc ATTRIBUTE_UNUSED,
const char *msgid, va_list *ap) const char *msgid, va_list *ap)
ATTRIBUTE_FPTR_PRINTF(5,0) ATTRIBUTE_FPTR_PRINTF(5,0)
{ {
char *msg = xvasprintf (msgid, *ap); char *msg = xvasprintf (msgid, *ap);
s_singleton->m_errors.safe_push (msg); s_singleton->m_diagnostics.safe_push (msg);
return true; return true;
} }
auto_vec<char *> m_errors; auto_vec<char *> m_diagnostics;
private: private:
static lexer_error_sink *s_singleton; static lexer_diagnostic_sink *s_singleton;
}; };
lexer_error_sink *lexer_error_sink::s_singleton; lexer_diagnostic_sink *lexer_diagnostic_sink::s_singleton;
/* Constructor. Override line_table with a new instance based on CASE_, /* Constructor. Override line_table with a new instance based on CASE_,
and write CONTENT to a tempfile. Create a cpp_reader, and use it to and write CONTENT to a tempfile. Create a cpp_reader, and use it to
...@@ -3413,21 +3413,21 @@ test_lexer_string_locations_raw_string_unterminated (const line_table_case &case ...@@ -3413,21 +3413,21 @@ test_lexer_string_locations_raw_string_unterminated (const line_table_case &case
{ {
const char *content = "R\"ouch()ouCh\" /* etc */"; const char *content = "R\"ouch()ouCh\" /* etc */";
lexer_error_sink errors; lexer_diagnostic_sink diagnostics;
lexer_test test (case_, content, &errors); lexer_test test (case_, content, &diagnostics);
test.m_implicitly_expect_EOF = false; test.m_implicitly_expect_EOF = false;
/* Attempt to parse the raw string. */ /* Attempt to parse the raw string. */
const cpp_token *tok = test.get_token (); const cpp_token *tok = test.get_token ();
ASSERT_EQ (tok->type, CPP_EOF); ASSERT_EQ (tok->type, CPP_EOF);
ASSERT_EQ (1, errors.m_errors.length ()); ASSERT_EQ (1, diagnostics.m_diagnostics.length ());
/* We expect the message "unterminated raw string" /* We expect the message "unterminated raw string"
in the "cpplib" translation domain. in the "cpplib" translation domain.
It's not clear that dgettext is available on all supported hosts, It's not clear that dgettext is available on all supported hosts,
so this assertion is commented-out for now. so this assertion is commented-out for now.
ASSERT_STREQ (dgettext ("cpplib", "unterminated raw string"), ASSERT_STREQ (dgettext ("cpplib", "unterminated raw string"),
errors.m_errors[0]); diagnostics.m_diagnostics[0]);
*/ */
} }
......
...@@ -503,8 +503,10 @@ print "/* Mapping from cpp message reasons to the options that enable them. */" ...@@ -503,8 +503,10 @@ print "/* Mapping from cpp message reasons to the options that enable them. */"
print "#include <cpplib.h>" print "#include <cpplib.h>"
print "struct cpp_reason_option_codes_t" print "struct cpp_reason_option_codes_t"
print "{" print "{"
print " const int reason; /* cpplib message reason. */" print " /* cpplib message reason. */"
print " const int option_code; /* gcc option that controls this message. */" print " const enum cpp_warning_reason reason;"
print " /* gcc option that controls this message. */"
print " const int option_code;"
print "};" print "};"
print "" print ""
print "static const struct cpp_reason_option_codes_t cpp_reason_option_codes[] = {" print "static const struct cpp_reason_option_codes_t cpp_reason_option_codes[] = {"
......
2018-10-09 David Malcolm <dmalcolm@redhat.com>
* charset.c (noop_error_cb): Rename to...
(noop_diagnostic_cb): ...this, converting params to enums.
(cpp_interpret_string_ranges): Update for renaming and enums.
* directives.c (check_eol_1): Convert reason to enum.
(do_diagnostic): Convert code and reason to enum.
(do_error): Use CPP_W_NONE rather than 0.
(do_pragma_dependency): Likewise.
* errors.c (cpp_diagnostic_at): Convert level and reason to enums.
Update for renaming.
(cpp_diagnostic): Convert level and reason to enums.
(cpp_error): Convert level to enum.
(cpp_warning): Convert reason to enums.
(cpp_pedwarning): Likewise.
(cpp_warning_syshdr): Likewise.
(cpp_diagnostic_with_line): Convert level and reason to enums.
Update for renaming.
(cpp_error_with_line): Convert level to enum.
(cpp_warning_with_line): Convert reason to enums.
(cpp_pedwarning_with_line): Likewise.
(cpp_warning_with_line_syshdr): Likewise.
(cpp_error_at): Convert level to enum.
(cpp_errno): Likewise.
(cpp_errno_filename): Likewise.
* include/cpplib.h (enum cpp_diagnostic_level): Name this enum,
and move to before struct cpp_callbacks.
(enum cpp_warning_reason): Likewise.
(cpp_callbacks::diagnostic): Convert params from int to enums.
(cpp_error): Convert int param to enum cpp_diagnostic_level.
(cpp_warning): Convert int param to enum cpp_warning_reason.
(cpp_pedwarning): Likewise.
(cpp_warning_syshdr): Likewise.
(cpp_errno): Convert int param to enum cpp_diagnostic_level.
(cpp_errno_filename): Likewise.
(cpp_error_with_line): Likewise.
(cpp_warning_with_line): Convert int param to enum
cpp_warning_reason.
(cpp_pedwarning_with_line): Likewise.
(cpp_warning_with_line_syshdr): Likewise.
(cpp_error_at): Convert int param to enum cpp_diagnostic_level.
* macro.c (create_iso_definition): Convert int to enum.
(_cpp_create_definition): Likewise.
2018-09-17 David Malcolm <dmalcolm@redhat.com> 2018-09-17 David Malcolm <dmalcolm@redhat.com>
* include/line-map.h (range_label::get_text): Add param * include/line-map.h (range_label::get_text): Add param
......
...@@ -1693,12 +1693,13 @@ cpp_interpret_string (cpp_reader *pfile, const cpp_string *from, size_t count, ...@@ -1693,12 +1693,13 @@ cpp_interpret_string (cpp_reader *pfile, const cpp_string *from, size_t count,
return cpp_interpret_string_1 (pfile, from, count, to, type, NULL, NULL); return cpp_interpret_string_1 (pfile, from, count, to, type, NULL, NULL);
} }
/* A "do nothing" error-handling callback for use by /* A "do nothing" diagnostic-handling callback for use by
cpp_interpret_string_ranges, so that it can temporarily suppress cpp_interpret_string_ranges, so that it can temporarily suppress
error-handling. */ diagnostic-handling. */
static bool static bool
noop_error_cb (cpp_reader *, int, int, rich_location *, noop_diagnostic_cb (cpp_reader *, enum cpp_diagnostic_level,
enum cpp_warning_reason, rich_location *,
const char *, va_list *) const char *, va_list *)
{ {
/* no-op. */ /* no-op. */
...@@ -1737,25 +1738,26 @@ cpp_interpret_string_ranges (cpp_reader *pfile, const cpp_string *from, ...@@ -1737,25 +1738,26 @@ cpp_interpret_string_ranges (cpp_reader *pfile, const cpp_string *from,
return "execution character set != source character set"; return "execution character set != source character set";
/* For on-demand strings we have already lexed the strings, so there /* For on-demand strings we have already lexed the strings, so there
should be no errors. However, if we have bogus source location should be no diagnostics. However, if we have bogus source location
data (or stringified macro arguments), the attempt to lex the data (or stringified macro arguments), the attempt to lex the
strings could fail with an error. Temporarily install an strings could fail with an diagnostic. Temporarily install an
error-handler to catch the error, so that it can lead to this call diagnostic-handler to catch the diagnostic, so that it can lead to this call
failing, rather than being emitted as a user-visible diagnostic. failing, rather than being emitted as a user-visible diagnostic.
If an error does occur, we should see it via the return value of If an diagnostic does occur, we should see it via the return value of
cpp_interpret_string_1. */ cpp_interpret_string_1. */
bool (*saved_error_handler) (cpp_reader *, int, int, rich_location *, bool (*saved_diagnostic_handler) (cpp_reader *, enum cpp_diagnostic_level,
enum cpp_warning_reason, rich_location *,
const char *, va_list *) const char *, va_list *)
ATTRIBUTE_FPTR_PRINTF(5,0); ATTRIBUTE_FPTR_PRINTF(5,0);
saved_error_handler = pfile->cb.error; saved_diagnostic_handler = pfile->cb.diagnostic;
pfile->cb.error = noop_error_cb; pfile->cb.diagnostic = noop_diagnostic_cb;
bool result = cpp_interpret_string_1 (pfile, from, count, NULL, type, bool result = cpp_interpret_string_1 (pfile, from, count, NULL, type,
loc_readers, out); loc_readers, out);
/* Restore the saved error-handler. */ /* Restore the saved diagnostic-handler. */
pfile->cb.error = saved_error_handler; pfile->cb.diagnostic = saved_diagnostic_handler;
if (!result) if (!result)
return "cpp_interpret_string_1 failed"; return "cpp_interpret_string_1 failed";
......
...@@ -102,7 +102,8 @@ static const char *parse_include (cpp_reader *, int *, const cpp_token ***, ...@@ -102,7 +102,8 @@ static const char *parse_include (cpp_reader *, int *, const cpp_token ***,
static void push_conditional (cpp_reader *, int, int, const cpp_hashnode *); static void push_conditional (cpp_reader *, int, int, const cpp_hashnode *);
static unsigned int read_flag (cpp_reader *, unsigned int); static unsigned int read_flag (cpp_reader *, unsigned int);
static bool strtolinenum (const uchar *, size_t, linenum_type *, bool *); static bool strtolinenum (const uchar *, size_t, linenum_type *, bool *);
static void do_diagnostic (cpp_reader *, int, int, int); static void do_diagnostic (cpp_reader *, enum cpp_diagnostic_level code,
enum cpp_warning_reason reason, int);
static cpp_hashnode *lex_macro_node (cpp_reader *, bool); static cpp_hashnode *lex_macro_node (cpp_reader *, bool);
static int undefine_macros (cpp_reader *, cpp_hashnode *, void *); static int undefine_macros (cpp_reader *, cpp_hashnode *, void *);
static void do_include_common (cpp_reader *, enum include_type); static void do_include_common (cpp_reader *, enum include_type);
...@@ -227,7 +228,7 @@ skip_rest_of_line (cpp_reader *pfile) ...@@ -227,7 +228,7 @@ skip_rest_of_line (cpp_reader *pfile)
/* Helper function for check_oel. */ /* Helper function for check_oel. */
static void static void
check_eol_1 (cpp_reader *pfile, bool expand, int reason) check_eol_1 (cpp_reader *pfile, bool expand, enum cpp_warning_reason reason)
{ {
if (! SEEN_EOL () && (expand if (! SEEN_EOL () && (expand
? cpp_get_token (pfile) ? cpp_get_token (pfile)
...@@ -1140,7 +1141,8 @@ _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason, ...@@ -1140,7 +1141,8 @@ _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason,
/* Report a warning or error detected by the program we are /* Report a warning or error detected by the program we are
processing. Use the directive's tokens in the error message. */ processing. Use the directive's tokens in the error message. */
static void static void
do_diagnostic (cpp_reader *pfile, int code, int reason, int print_dir) do_diagnostic (cpp_reader *pfile, enum cpp_diagnostic_level code,
enum cpp_warning_reason reason, int print_dir)
{ {
const unsigned char *dir_name; const unsigned char *dir_name;
unsigned char *line; unsigned char *line;
...@@ -1166,7 +1168,7 @@ do_diagnostic (cpp_reader *pfile, int code, int reason, int print_dir) ...@@ -1166,7 +1168,7 @@ do_diagnostic (cpp_reader *pfile, int code, int reason, int print_dir)
static void static void
do_error (cpp_reader *pfile) do_error (cpp_reader *pfile)
{ {
do_diagnostic (pfile, CPP_DL_ERROR, 0, 1); do_diagnostic (pfile, CPP_DL_ERROR, CPP_W_NONE, 1);
} }
static void static void
...@@ -1720,7 +1722,7 @@ do_pragma_dependency (cpp_reader *pfile) ...@@ -1720,7 +1722,7 @@ do_pragma_dependency (cpp_reader *pfile)
if (cpp_get_token (pfile)->type != CPP_EOF) if (cpp_get_token (pfile)->type != CPP_EOF)
{ {
_cpp_backup_tokens (pfile, 1); _cpp_backup_tokens (pfile, 1);
do_diagnostic (pfile, CPP_DL_WARNING, 0, 0); do_diagnostic (pfile, CPP_DL_WARNING, CPP_W_NONE, 0);
} }
} }
......
...@@ -31,15 +31,15 @@ along with this program; see the file COPYING3. If not see ...@@ -31,15 +31,15 @@ along with this program; see the file COPYING3. If not see
ATTRIBUTE_FPTR_PRINTF(5,0) ATTRIBUTE_FPTR_PRINTF(5,0)
static bool static bool
cpp_diagnostic_at (cpp_reader * pfile, int level, int reason, cpp_diagnostic_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
rich_location *richloc, enum cpp_warning_reason reason, rich_location *richloc,
const char *msgid, va_list *ap) const char *msgid, va_list *ap)
{ {
bool ret; bool ret;
if (!pfile->cb.error) if (!pfile->cb.diagnostic)
abort (); abort ();
ret = pfile->cb.error (pfile, level, reason, richloc, _(msgid), ap); ret = pfile->cb.diagnostic (pfile, level, reason, richloc, _(msgid), ap);
return ret; return ret;
} }
...@@ -48,7 +48,8 @@ cpp_diagnostic_at (cpp_reader * pfile, int level, int reason, ...@@ -48,7 +48,8 @@ cpp_diagnostic_at (cpp_reader * pfile, int level, int reason,
ATTRIBUTE_FPTR_PRINTF(4,0) ATTRIBUTE_FPTR_PRINTF(4,0)
static bool static bool
cpp_diagnostic (cpp_reader * pfile, int level, int reason, cpp_diagnostic (cpp_reader * pfile, enum cpp_diagnostic_level level,
enum cpp_warning_reason reason,
const char *msgid, va_list *ap) const char *msgid, va_list *ap)
{ {
source_location src_loc; source_location src_loc;
...@@ -77,7 +78,8 @@ cpp_diagnostic (cpp_reader * pfile, int level, int reason, ...@@ -77,7 +78,8 @@ cpp_diagnostic (cpp_reader * pfile, int level, int reason,
/* Print a warning or error, depending on the value of LEVEL. */ /* Print a warning or error, depending on the value of LEVEL. */
bool bool
cpp_error (cpp_reader * pfile, int level, const char *msgid, ...) cpp_error (cpp_reader * pfile, enum cpp_diagnostic_level level,
const char *msgid, ...)
{ {
va_list ap; va_list ap;
bool ret; bool ret;
...@@ -93,7 +95,8 @@ cpp_error (cpp_reader * pfile, int level, const char *msgid, ...) ...@@ -93,7 +95,8 @@ cpp_error (cpp_reader * pfile, int level, const char *msgid, ...)
/* Print a warning. The warning reason may be given in REASON. */ /* Print a warning. The warning reason may be given in REASON. */
bool bool
cpp_warning (cpp_reader * pfile, int reason, const char *msgid, ...) cpp_warning (cpp_reader * pfile, enum cpp_warning_reason reason,
const char *msgid, ...)
{ {
va_list ap; va_list ap;
bool ret; bool ret;
...@@ -109,7 +112,8 @@ cpp_warning (cpp_reader * pfile, int reason, const char *msgid, ...) ...@@ -109,7 +112,8 @@ cpp_warning (cpp_reader * pfile, int reason, const char *msgid, ...)
/* Print a pedantic warning. The warning reason may be given in REASON. */ /* Print a pedantic warning. The warning reason may be given in REASON. */
bool bool
cpp_pedwarning (cpp_reader * pfile, int reason, const char *msgid, ...) cpp_pedwarning (cpp_reader * pfile, enum cpp_warning_reason reason,
const char *msgid, ...)
{ {
va_list ap; va_list ap;
bool ret; bool ret;
...@@ -126,7 +130,8 @@ cpp_pedwarning (cpp_reader * pfile, int reason, const char *msgid, ...) ...@@ -126,7 +130,8 @@ cpp_pedwarning (cpp_reader * pfile, int reason, const char *msgid, ...)
given in REASON. */ given in REASON. */
bool bool
cpp_warning_syshdr (cpp_reader * pfile, int reason, const char *msgid, ...) cpp_warning_syshdr (cpp_reader * pfile, enum cpp_warning_reason reason,
const char *msgid, ...)
{ {
va_list ap; va_list ap;
bool ret; bool ret;
...@@ -143,18 +148,19 @@ cpp_warning_syshdr (cpp_reader * pfile, int reason, const char *msgid, ...) ...@@ -143,18 +148,19 @@ cpp_warning_syshdr (cpp_reader * pfile, int reason, const char *msgid, ...)
ATTRIBUTE_FPTR_PRINTF(6,0) ATTRIBUTE_FPTR_PRINTF(6,0)
static bool static bool
cpp_diagnostic_with_line (cpp_reader * pfile, int level, int reason, cpp_diagnostic_with_line (cpp_reader * pfile, enum cpp_diagnostic_level level,
enum cpp_warning_reason reason,
source_location src_loc, unsigned int column, source_location src_loc, unsigned int column,
const char *msgid, va_list *ap) const char *msgid, va_list *ap)
{ {
bool ret; bool ret;
if (!pfile->cb.error) if (!pfile->cb.diagnostic)
abort (); abort ();
rich_location richloc (pfile->line_table, src_loc); rich_location richloc (pfile->line_table, src_loc);
if (column) if (column)
richloc.override_column (column); richloc.override_column (column);
ret = pfile->cb.error (pfile, level, reason, &richloc, _(msgid), ap); ret = pfile->cb.diagnostic (pfile, level, reason, &richloc, _(msgid), ap);
return ret; return ret;
} }
...@@ -162,7 +168,7 @@ cpp_diagnostic_with_line (cpp_reader * pfile, int level, int reason, ...@@ -162,7 +168,7 @@ cpp_diagnostic_with_line (cpp_reader * pfile, int level, int reason,
/* Print a warning or error, depending on the value of LEVEL. */ /* Print a warning or error, depending on the value of LEVEL. */
bool bool
cpp_error_with_line (cpp_reader *pfile, int level, cpp_error_with_line (cpp_reader *pfile, enum cpp_diagnostic_level level,
source_location src_loc, unsigned int column, source_location src_loc, unsigned int column,
const char *msgid, ...) const char *msgid, ...)
{ {
...@@ -181,7 +187,7 @@ cpp_error_with_line (cpp_reader *pfile, int level, ...@@ -181,7 +187,7 @@ cpp_error_with_line (cpp_reader *pfile, int level,
/* Print a warning. The warning reason may be given in REASON. */ /* Print a warning. The warning reason may be given in REASON. */
bool bool
cpp_warning_with_line (cpp_reader *pfile, int reason, cpp_warning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason,
source_location src_loc, unsigned int column, source_location src_loc, unsigned int column,
const char *msgid, ...) const char *msgid, ...)
{ {
...@@ -200,7 +206,7 @@ cpp_warning_with_line (cpp_reader *pfile, int reason, ...@@ -200,7 +206,7 @@ cpp_warning_with_line (cpp_reader *pfile, int reason,
/* Print a pedantic warning. The warning reason may be given in REASON. */ /* Print a pedantic warning. The warning reason may be given in REASON. */
bool bool
cpp_pedwarning_with_line (cpp_reader *pfile, int reason, cpp_pedwarning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason,
source_location src_loc, unsigned int column, source_location src_loc, unsigned int column,
const char *msgid, ...) const char *msgid, ...)
{ {
...@@ -220,7 +226,7 @@ cpp_pedwarning_with_line (cpp_reader *pfile, int reason, ...@@ -220,7 +226,7 @@ cpp_pedwarning_with_line (cpp_reader *pfile, int reason,
given in REASON. */ given in REASON. */
bool bool
cpp_warning_with_line_syshdr (cpp_reader *pfile, int reason, cpp_warning_with_line_syshdr (cpp_reader *pfile, enum cpp_warning_reason reason,
source_location src_loc, unsigned int column, source_location src_loc, unsigned int column,
const char *msgid, ...) const char *msgid, ...)
{ {
...@@ -240,8 +246,8 @@ cpp_warning_with_line_syshdr (cpp_reader *pfile, int reason, ...@@ -240,8 +246,8 @@ cpp_warning_with_line_syshdr (cpp_reader *pfile, int reason,
a column override. */ a column override. */
bool bool
cpp_error_at (cpp_reader * pfile, int level, source_location src_loc, cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
const char *msgid, ...) source_location src_loc, const char *msgid, ...)
{ {
va_list ap; va_list ap;
bool ret; bool ret;
...@@ -260,8 +266,8 @@ cpp_error_at (cpp_reader * pfile, int level, source_location src_loc, ...@@ -260,8 +266,8 @@ cpp_error_at (cpp_reader * pfile, int level, source_location src_loc,
a column override. */ a column override. */
bool bool
cpp_error_at (cpp_reader * pfile, int level, rich_location *richloc, cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
const char *msgid, ...) rich_location *richloc, const char *msgid, ...)
{ {
va_list ap; va_list ap;
bool ret; bool ret;
...@@ -279,7 +285,8 @@ cpp_error_at (cpp_reader * pfile, int level, rich_location *richloc, ...@@ -279,7 +285,8 @@ cpp_error_at (cpp_reader * pfile, int level, rich_location *richloc,
information from errno. */ information from errno. */
bool bool
cpp_errno (cpp_reader *pfile, int level, const char *msgid) cpp_errno (cpp_reader *pfile, enum cpp_diagnostic_level level,
const char *msgid)
{ {
return cpp_error (pfile, level, "%s: %s", _(msgid), xstrerror (errno)); return cpp_error (pfile, level, "%s: %s", _(msgid), xstrerror (errno));
} }
...@@ -289,7 +296,8 @@ cpp_errno (cpp_reader *pfile, int level, const char *msgid) ...@@ -289,7 +296,8 @@ cpp_errno (cpp_reader *pfile, int level, const char *msgid)
that is not localized, but "" is replaced with localized "stdout". */ that is not localized, but "" is replaced with localized "stdout". */
bool bool
cpp_errno_filename (cpp_reader *pfile, int level, const char *filename, cpp_errno_filename (cpp_reader *pfile, enum cpp_diagnostic_level level,
const char *filename,
source_location loc) source_location loc)
{ {
if (filename[0] == '\0') if (filename[0] == '\0')
......
...@@ -549,6 +549,59 @@ struct cpp_options ...@@ -549,6 +549,59 @@ struct cpp_options
bool canonical_system_headers; bool canonical_system_headers;
}; };
/* 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. */
enum cpp_diagnostic_level {
/* Warning, an error with -Werror. */
CPP_DL_WARNING = 0,
/* Same as CPP_DL_WARNING, except it is not suppressed in system headers. */
CPP_DL_WARNING_SYSHDR,
/* Warning, an error with -pedantic-errors or -Werror. */
CPP_DL_PEDWARN,
/* An error. */
CPP_DL_ERROR,
/* An internal consistency check failed. Prints "internal error: ",
otherwise the same as CPP_DL_ERROR. */
CPP_DL_ICE,
/* An informative note following a warning. */
CPP_DL_NOTE,
/* A fatal error. */
CPP_DL_FATAL
};
/* Warning reason codes. Use a reason code of CPP_W_NONE for unclassified
warnings and diagnostics that are not warnings. */
enum cpp_warning_reason {
CPP_W_NONE = 0,
CPP_W_DEPRECATED,
CPP_W_COMMENTS,
CPP_W_MISSING_INCLUDE_DIRS,
CPP_W_TRIGRAPHS,
CPP_W_MULTICHAR,
CPP_W_TRADITIONAL,
CPP_W_LONG_LONG,
CPP_W_ENDIF_LABELS,
CPP_W_NUM_SIGN_CHANGE,
CPP_W_VARIADIC_MACROS,
CPP_W_BUILTIN_MACRO_REDEFINED,
CPP_W_DOLLARS,
CPP_W_UNDEF,
CPP_W_UNUSED_MACROS,
CPP_W_CXX_OPERATOR_NAMES,
CPP_W_NORMALIZE,
CPP_W_INVALID_PCH,
CPP_W_WARNING_DIRECTIVE,
CPP_W_LITERAL_SUFFIX,
CPP_W_DATE_TIME,
CPP_W_PEDANTIC,
CPP_W_C90_C99_COMPAT,
CPP_W_CXX11_COMPAT,
CPP_W_EXPANSION_TO_DEFINED
};
/* Callback for header lookup for HEADER, which is the name of a /* Callback for header lookup for HEADER, which is the name of a
source file. It is used as a method of last resort to find headers source file. It is used as a method of last resort to find headers
that are not otherwise found during the normal include processing. that are not otherwise found during the normal include processing.
...@@ -586,7 +639,10 @@ struct cpp_callbacks ...@@ -586,7 +639,10 @@ struct cpp_callbacks
/* Called to emit a diagnostic. This callback receives the /* Called to emit a diagnostic. This callback receives the
translated message. */ translated message. */
bool (*error) (cpp_reader *, int, int, rich_location *, bool (*diagnostic) (cpp_reader *,
enum cpp_diagnostic_level,
enum cpp_warning_reason,
rich_location *,
const char *, va_list *) const char *, va_list *)
ATTRIBUTE_FPTR_PRINTF(5,0); ATTRIBUTE_FPTR_PRINTF(5,0);
...@@ -1084,99 +1140,55 @@ extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *, ...@@ -1084,99 +1140,55 @@ extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *,
others assumed clear, to fill out a cpp_num structure. */ others assumed clear, to fill out a cpp_num structure. */
cpp_num cpp_num_sign_extend (cpp_num, size_t); cpp_num cpp_num_sign_extend (cpp_num, size_t);
/* 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. */
enum {
/* Warning, an error with -Werror. */
CPP_DL_WARNING = 0,
/* Same as CPP_DL_WARNING, except it is not suppressed in system headers. */
CPP_DL_WARNING_SYSHDR,
/* Warning, an error with -pedantic-errors or -Werror. */
CPP_DL_PEDWARN,
/* An error. */
CPP_DL_ERROR,
/* An internal consistency check failed. Prints "internal error: ",
otherwise the same as CPP_DL_ERROR. */
CPP_DL_ICE,
/* An informative note following a warning. */
CPP_DL_NOTE,
/* A fatal error. */
CPP_DL_FATAL
};
/* Warning reason codes. Use a reason code of zero for unclassified warnings
and errors that are not warnings. */
enum {
CPP_W_NONE = 0,
CPP_W_DEPRECATED,
CPP_W_COMMENTS,
CPP_W_MISSING_INCLUDE_DIRS,
CPP_W_TRIGRAPHS,
CPP_W_MULTICHAR,
CPP_W_TRADITIONAL,
CPP_W_LONG_LONG,
CPP_W_ENDIF_LABELS,
CPP_W_NUM_SIGN_CHANGE,
CPP_W_VARIADIC_MACROS,
CPP_W_BUILTIN_MACRO_REDEFINED,
CPP_W_DOLLARS,
CPP_W_UNDEF,
CPP_W_UNUSED_MACROS,
CPP_W_CXX_OPERATOR_NAMES,
CPP_W_NORMALIZE,
CPP_W_INVALID_PCH,
CPP_W_WARNING_DIRECTIVE,
CPP_W_LITERAL_SUFFIX,
CPP_W_DATE_TIME,
CPP_W_PEDANTIC,
CPP_W_C90_C99_COMPAT,
CPP_W_CXX11_COMPAT,
CPP_W_EXPANSION_TO_DEFINED
};
/* Output a diagnostic of some kind. */ /* Output a diagnostic of some kind. */
extern bool cpp_error (cpp_reader *, int, const char *msgid, ...) extern bool cpp_error (cpp_reader *, enum cpp_diagnostic_level,
const char *msgid, ...)
ATTRIBUTE_PRINTF_3; ATTRIBUTE_PRINTF_3;
extern bool cpp_warning (cpp_reader *, int, const char *msgid, ...) extern bool cpp_warning (cpp_reader *, enum cpp_warning_reason,
const char *msgid, ...)
ATTRIBUTE_PRINTF_3; ATTRIBUTE_PRINTF_3;
extern bool cpp_pedwarning (cpp_reader *, int, const char *msgid, ...) extern bool cpp_pedwarning (cpp_reader *, enum cpp_warning_reason,
const char *msgid, ...)
ATTRIBUTE_PRINTF_3; ATTRIBUTE_PRINTF_3;
extern bool cpp_warning_syshdr (cpp_reader *, int, const char *msgid, ...) extern bool cpp_warning_syshdr (cpp_reader *, enum cpp_warning_reason reason,
const char *msgid, ...)
ATTRIBUTE_PRINTF_3; ATTRIBUTE_PRINTF_3;
/* Output a diagnostic with "MSGID: " preceding the /* Output a diagnostic with "MSGID: " preceding the
error string of errno. No location is printed. */ error string of errno. No location is printed. */
extern bool cpp_errno (cpp_reader *, int, const char *msgid); extern bool cpp_errno (cpp_reader *, enum cpp_diagnostic_level,
const char *msgid);
/* Similarly, but with "FILENAME: " instead of "MSGID: ", where /* Similarly, but with "FILENAME: " instead of "MSGID: ", where
the filename is not localized. */ the filename is not localized. */
extern bool cpp_errno_filename (cpp_reader *, int, const char *filename, extern bool cpp_errno_filename (cpp_reader *, enum cpp_diagnostic_level,
source_location loc); const char *filename, source_location loc);
/* Same as cpp_error, except additionally specifies a position as a /* Same as cpp_error, except additionally specifies a position as a
(translation unit) physical line and physical column. If the line is (translation unit) physical line and physical column. If the line is
zero, then no location is printed. */ zero, then no location is printed. */
extern bool cpp_error_with_line (cpp_reader *, int, source_location, extern bool cpp_error_with_line (cpp_reader *, enum cpp_diagnostic_level,
unsigned, const char *msgid, ...) source_location, unsigned,
const char *msgid, ...)
ATTRIBUTE_PRINTF_5; ATTRIBUTE_PRINTF_5;
extern bool cpp_warning_with_line (cpp_reader *, int, source_location, extern bool cpp_warning_with_line (cpp_reader *, enum cpp_warning_reason,
unsigned, const char *msgid, ...) source_location, unsigned,
const char *msgid, ...)
ATTRIBUTE_PRINTF_5; ATTRIBUTE_PRINTF_5;
extern bool cpp_pedwarning_with_line (cpp_reader *, int, source_location, extern bool cpp_pedwarning_with_line (cpp_reader *, enum cpp_warning_reason,
unsigned, const char *msgid, ...) source_location, unsigned,
const char *msgid, ...)
ATTRIBUTE_PRINTF_5; ATTRIBUTE_PRINTF_5;
extern bool cpp_warning_with_line_syshdr (cpp_reader *, int, source_location, extern bool cpp_warning_with_line_syshdr (cpp_reader *, enum cpp_warning_reason,
unsigned, const char *msgid, ...) source_location, unsigned,
const char *msgid, ...)
ATTRIBUTE_PRINTF_5; ATTRIBUTE_PRINTF_5;
extern bool cpp_error_at (cpp_reader * pfile, int level, extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
source_location src_loc, const char *msgid, ...) source_location src_loc, const char *msgid, ...)
ATTRIBUTE_PRINTF_4; ATTRIBUTE_PRINTF_4;
extern bool cpp_error_at (cpp_reader * pfile, int level, extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
rich_location *richloc, const char *msgid, rich_location *richloc, const char *msgid, ...)
...)
ATTRIBUTE_PRINTF_4; ATTRIBUTE_PRINTF_4;
/* In lex.c */ /* In lex.c */
......
...@@ -3297,7 +3297,7 @@ create_iso_definition (cpp_reader *pfile) ...@@ -3297,7 +3297,7 @@ create_iso_definition (cpp_reader *pfile)
: N_("ISO C99 requires whitespace after the macro name")); : N_("ISO C99 requires whitespace after the macro name"));
else else
{ {
int warntype = CPP_DL_WARNING; enum cpp_diagnostic_level warntype = CPP_DL_WARNING;
switch (token->type) switch (token->type)
{ {
case CPP_ATSIGN: case CPP_ATSIGN:
...@@ -3512,7 +3512,7 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node) ...@@ -3512,7 +3512,7 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node)
if (warn_of_redefinition (pfile, node, macro)) if (warn_of_redefinition (pfile, node, macro))
{ {
const int reason const enum cpp_warning_reason reason
= (cpp_builtin_macro_p (node) && !(node->flags & NODE_WARN)) = (cpp_builtin_macro_p (node) && !(node->flags & NODE_WARN))
? CPP_W_BUILTIN_MACRO_REDEFINED : CPP_W_NONE; ? CPP_W_BUILTIN_MACRO_REDEFINED : CPP_W_NONE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment