summaryrefslogtreecommitdiff
path: root/libcpp/charset.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2018-10-09 23:37:19 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-10-09 23:37:19 +0000
commitc24300baea50482b6788041fbac9a6f197c490fc (patch)
treed3e437990f8267770cb8b4857529ff0c2c7ab49e /libcpp/charset.c
parent5abdb369eb2f38272bb8ee2ea0488194942c7cff (diff)
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 'libcpp/charset.c')
-rw-r--r--libcpp/charset.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/libcpp/charset.c b/libcpp/charset.c
index c6dce0d063e..36c57a6a046 100644
--- a/libcpp/charset.c
+++ b/libcpp/charset.c
@@ -1693,13 +1693,14 @@ 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);
}
-/* 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
- error-handling. */
+ diagnostic-handling. */
static bool
-noop_error_cb (cpp_reader *, int, int, rich_location *,
- const char *, va_list *)
+noop_diagnostic_cb (cpp_reader *, enum cpp_diagnostic_level,
+ enum cpp_warning_reason, rich_location *,
+ const char *, va_list *)
{
/* no-op. */
return true;
@@ -1737,25 +1738,26 @@ cpp_interpret_string_ranges (cpp_reader *pfile, const cpp_string *from,
return "execution character set != source character set";
/* 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
- strings could fail with an error. Temporarily install an
- error-handler to catch the error, so that it can lead to this call
+ strings could fail with an diagnostic. Temporarily install an
+ diagnostic-handler to catch the diagnostic, so that it can lead to this call
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. */
- bool (*saved_error_handler) (cpp_reader *, int, int, rich_location *,
- const char *, va_list *)
+ 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);
- saved_error_handler = pfile->cb.error;
- pfile->cb.error = noop_error_cb;
+ saved_diagnostic_handler = pfile->cb.diagnostic;
+ pfile->cb.diagnostic = noop_diagnostic_cb;
bool result = cpp_interpret_string_1 (pfile, from, count, NULL, type,
loc_readers, out);
- /* Restore the saved error-handler. */
- pfile->cb.error = saved_error_handler;
+ /* Restore the saved diagnostic-handler. */
+ pfile->cb.diagnostic = saved_diagnostic_handler;
if (!result)
return "cpp_interpret_string_1 failed";