diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-10-09 23:37:19 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-10-09 23:37:19 +0000 |
commit | c24300baea50482b6788041fbac9a6f197c490fc (patch) | |
tree | d3e437990f8267770cb8b4857529ff0c2c7ab49e /gcc/input.c | |
parent | 5abdb369eb2f38272bb8ee2ea0488194942c7cff (diff) | |
download | gcc-c24300baea50482b6788041fbac9a6f197c490fc.zip gcc-c24300baea50482b6788041fbac9a6f197c490fc.tar.gz gcc-c24300baea50482b6788041fbac9a6f197c490fc.tar.bz2 |
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
Diffstat (limited to 'gcc/input.c')
-rw-r--r-- | gcc/input.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/gcc/input.c b/gcc/input.c index b4b7136..eeeb11e 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -2116,14 +2116,14 @@ class ebcdic_execution_charset : public lexer_test_options cpp_opts->narrow_charset = "IBM1047"; 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, - int level ATTRIBUTE_UNUSED, - int reason ATTRIBUTE_UNUSED, - rich_location *richloc ATTRIBUTE_UNUSED, - const char *msgid, va_list *ap ATTRIBUTE_UNUSED) + static bool on_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED, + enum cpp_diagnostic_level level ATTRIBUTE_UNUSED, + enum cpp_warning_reason reason ATTRIBUTE_UNUSED, + rich_location *richloc ATTRIBUTE_UNUSED, + const char *msgid, va_list *ap ATTRIBUTE_UNUSED) ATTRIBUTE_FPTR_PRINTF(5,0) { gcc_assert (s_singleton); @@ -2153,53 +2153,53 @@ class ebcdic_execution_charset : public lexer_test_options 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. */ -class lexer_error_sink : public lexer_test_options +class lexer_diagnostic_sink : public lexer_test_options { public: - lexer_error_sink () + lexer_diagnostic_sink () { gcc_assert (s_singleton == NULL); s_singleton = this; } - ~lexer_error_sink () + ~lexer_diagnostic_sink () { gcc_assert (s_singleton == this); s_singleton = NULL; int i; char *str; - FOR_EACH_VEC_ELT (m_errors, i, str) + FOR_EACH_VEC_ELT (m_diagnostics, i, str) free (str); } void apply (lexer_test &test) FINAL OVERRIDE { 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, - int level ATTRIBUTE_UNUSED, - int reason ATTRIBUTE_UNUSED, - rich_location *richloc ATTRIBUTE_UNUSED, - const char *msgid, va_list *ap) + static bool on_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED, + enum cpp_diagnostic_level level ATTRIBUTE_UNUSED, + enum cpp_warning_reason reason ATTRIBUTE_UNUSED, + rich_location *richloc ATTRIBUTE_UNUSED, + const char *msgid, va_list *ap) ATTRIBUTE_FPTR_PRINTF(5,0) { char *msg = xvasprintf (msgid, *ap); - s_singleton->m_errors.safe_push (msg); + s_singleton->m_diagnostics.safe_push (msg); return true; } - auto_vec<char *> m_errors; + auto_vec<char *> m_diagnostics; 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_, 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 { const char *content = "R\"ouch()ouCh\" /* etc */"; - lexer_error_sink errors; - lexer_test test (case_, content, &errors); + lexer_diagnostic_sink diagnostics; + lexer_test test (case_, content, &diagnostics); test.m_implicitly_expect_EOF = false; /* Attempt to parse the raw string. */ const cpp_token *tok = test.get_token (); 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" in the "cpplib" translation domain. It's not clear that dgettext is available on all supported hosts, so this assertion is commented-out for now. ASSERT_STREQ (dgettext ("cpplib", "unterminated raw string"), - errors.m_errors[0]); + diagnostics.m_diagnostics[0]); */ } |