diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-09-09 19:38:13 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-09-09 19:38:13 -0400 |
commit | 89991f31c5ded21179b12a9f4063c2b8fabc2e3b (patch) | |
tree | e5decf04bdbb7f6379d38fb681546770e4ef36e8 /gcc/diagnostic-core.h | |
parent | a97448e92eb76a69b4183183d14a791f9b76cc8d (diff) | |
download | gcc-89991f31c5ded21179b12a9f4063c2b8fabc2e3b.zip gcc-89991f31c5ded21179b12a9f4063c2b8fabc2e3b.tar.gz gcc-89991f31c5ded21179b12a9f4063c2b8fabc2e3b.tar.bz2 |
diagnostics: introduce struct diagnostic_option_id
Use a new struct diagnostic_option_id rather than just "int" when
referring to command-line options controlling warnings in the
diagnostic subsystem.
No functional change intended, but better documents the meaning of
the code.
gcc/c-family/ChangeLog:
* c-common.cc (c_option_controlling_cpp_diagnostic): Return
diagnostic_option_id rather than int.
(c_cpp_diagnostic): Update for renaming of
diagnostic_override_option_index to diagnostic_set_option_id.
gcc/c/ChangeLog:
* c-errors.cc (pedwarn_c23): Use "diagnostic_option_id option_id"
rather than "int opt". Update for renaming of diagnostic_info
field.
(pedwarn_c11): Likewise.
(pedwarn_c99): Likewise.
(pedwarn_c90): Likewise.
* c-tree.h (pedwarn_c90): Likewise for decl.
(pedwarn_c99): Likewise.
(pedwarn_c11): Likewise.
(pedwarn_c23): Likewise.
gcc/cp/ChangeLog:
* constexpr.cc (constexpr_error): Update for renaming of
diagnostic_info field.
* cp-tree.h (pedwarn_cxx98): Use "diagnostic_option_id" rather
than "int".
* error.cc (cp_adjust_diagnostic_info): Update for renaming of
diagnostic_info field.
(pedwarn_cxx98): Use "diagnostic_option_id option_id" rather than
"int opt". Update for renaming of diagnostic_info field.
(diagnostic_set_info): Likewise.
gcc/d/ChangeLog:
* d-diagnostic.cc (d_diagnostic_report_diagnostic): Update for
renaming of diagnostic_info field.
gcc/ChangeLog:
* diagnostic-core.h (struct diagnostic_option_id): New.
(warning): Use it rather than "int" for param.
(warning_n): Likewise.
(warning_at): Likewise.
(warning_meta): Likewise.
(pedwarn): Likewise.
(permerror_opt): Likewise.
(emit_diagnostic): Likewise.
(emit_diagnostic_valist): Likewise.
(emit_diagnostic_valist_meta): Likewise.
* diagnostic-format-json.cc
(json_output_format::on_report_diagnostic): Update for renaming of
diagnostic_info field.
* diagnostic-format-sarif.cc (sarif_builder::make_result_object):
Likewise.
(make_reporting_descriptor_object_for_warning): Likewise.
* diagnostic-format-text.cc (print_option_information): Likewise.
* diagnostic-global-context.cc (emit_diagnostic): Use
"diagnostic_option_id option_id" rather than "int opt".
(emit_diagnostic_valist): Likewise.
(emit_diagnostic_valist_meta): Likewise.
(warning): Likewise.
(warning_at): Likewise.
(warning_meta): Likewise.
(warning_n): Likewise.
(pedwarn): Likewise.
(permerror_opt): Likewise.
* diagnostic.cc (diagnostic_set_info_translated): Update for
renaming of diagnostic_info field.
(diagnostic_option_classifier::classify_diagnostic): Use
"diagnostic_option_id option_id" rather than "int opt".
(update_effective_level_from_pragmas): Update for renaming of
diagnostic_info field.
(diagnostic_context::diagnostic_enabled): Likewise.
(diagnostic_context::warning_enabled_at): Use
"diagnostic_option_id option_id" rather than "int opt".
(diagnostic_context::diagnostic_impl): Likewise.
(diagnostic_context::diagnostic_n_impl): Likewise.
* diagnostic.h (diagnostic_info::diagnostic_info): Update for...
(diagnostic_info::option_index): Rename...
(diagnostic_info::option_id): ...to this.
(class diagnostic_option_manager): Use
"diagnostic_option_id option_id" rather than "int opt" for vfuncs.
(diagnostic_option_classifier): Likewise for member funcs.
(diagnostic_classification_change_t::option): Add comment.
(diagnostic_context::warning_enabled_at): Use
"diagnostic_option_id option_id" rather than "int option_index".
(diagnostic_context::option_unspecified_p): Likewise.
(diagnostic_context::classify_diagnostic): Likewise.
(diagnostic_context::option_enabled_p): Likewise.
(diagnostic_context::make_option_name): Likewise.
(diagnostic_context::make_option_url): Likewise.
(diagnostic_context::diagnostic_impl): Likewise.
(diagnostic_context::diagnostic_n_impl): Likewise.
(diagnostic_override_option_index): Rename...
(diagnostic_set_option_id): ...to this, and update for
diagnostic_info field renaming.
(diagnostic_classify_diagnostic): Use "diagnostic_option_id"
rather than "int".
(warning_enabled_at): Likewise.
(option_unspecified_p): Likewise.
gcc/fortran/ChangeLog:
* cpp.cc (cb_cpp_diagnostic_cpp_option): Convert return type from
"int" to "diagnostic_option_id".
(cb_cpp_diagnostic): Update for renaming of
diagnostic_override_option_index to diagnostic_set_option_id.
* error.cc (gfc_warning): Update for renaming of diagnostic_info
field.
(gfc_warning_now_at): Likewise.
(gfc_warning_now): Likewise.
(gfc_warning_internal): Likewise.
gcc/ChangeLog:
* ipa-pure-const.cc: Replace include of "opts.h" with
"opts-diagnostic.h".
(suggest_attribute): Convert param from int to
diagnostic_option_id.
* lto-wrapper.cc (class lto_diagnostic_option_manager): Use
diagnostic_option_id rather than "int".
* opts-common.cc
(compiler_diagnostic_option_manager::option_enabled_p): Likewise.
* opts-diagnostic.h (class gcc_diagnostic_option_manager):
Likewise.
(class compiler_diagnostic_option_manager): Likewise.
* opts.cc (compiler_diagnostic_option_manager::make_option_name):
Likewise.
(gcc_diagnostic_option_manager::make_option_url): Likewise.
* substring-locations.cc
(format_string_diagnostic_t::emit_warning_n_va): Likewise.
(format_string_diagnostic_t::emit_warning_va): Likewise.
(format_string_diagnostic_t::emit_warning): Likewise.
(format_string_diagnostic_t::emit_warning_n): Likewise.
* substring-locations.h
(format_string_diagnostic_t::emit_warning_va): Likewise.
(format_string_diagnostic_t::emit_warning_n_va): Likewise.
(format_string_diagnostic_t::emit_warning): Likewise.
(format_string_diagnostic_t::emit_warning_n): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/diagnostic-core.h')
-rw-r--r-- | gcc/diagnostic-core.h | 78 |
1 files changed, 62 insertions, 16 deletions
diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h index 8071cc1..0fddf25 100644 --- a/gcc/diagnostic-core.h +++ b/gcc/diagnostic-core.h @@ -51,6 +51,27 @@ class auto_diagnostic_group /* Forward decl. */ class diagnostic_metadata; /* See diagnostic-metadata.h. */ +/* A class to use for the ID of an option that controls + a particular diagnostic. + This is just a wrapper around "int", but better documents + the intent of the code. */ + +struct diagnostic_option_id +{ + diagnostic_option_id () : m_idx (0) {} + + diagnostic_option_id (int idx) : m_idx (idx) {} + /* Ideally we'd take an enum opt_code here, but we don't + want to depend on its decl. */ + + bool operator== (diagnostic_option_id other) const + { + return m_idx == other.m_idx; + } + + int m_idx; +}; + extern const char *progname; extern const char *trim_filename (const char *); @@ -73,19 +94,29 @@ extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2) extern void internal_error_no_backtrace (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2) ATTRIBUTE_NORETURN; /* Pass one of the OPT_W* from options.h as the first parameter. */ -extern bool warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); -extern bool warning_n (location_t, int, unsigned HOST_WIDE_INT, +extern bool warning (diagnostic_option_id, + const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); +extern bool warning_n (location_t, + diagnostic_option_id, + unsigned HOST_WIDE_INT, const char *, const char *, ...) ATTRIBUTE_GCC_DIAG(4,6) ATTRIBUTE_GCC_DIAG(5,6); -extern bool warning_n (rich_location *, int, unsigned HOST_WIDE_INT, +extern bool warning_n (rich_location *, + diagnostic_option_id, + unsigned HOST_WIDE_INT, const char *, const char *, ...) ATTRIBUTE_GCC_DIAG(4, 6) ATTRIBUTE_GCC_DIAG(5, 6); -extern bool warning_at (location_t, int, const char *, ...) +extern bool warning_at (location_t, + diagnostic_option_id, + const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); -extern bool warning_at (rich_location *, int, const char *, ...) +extern bool warning_at (rich_location *, + diagnostic_option_id, + const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); extern bool warning_meta (rich_location *, - const diagnostic_metadata &, int, + const diagnostic_metadata &, + diagnostic_option_id, const char *, ...) ATTRIBUTE_GCC_DIAG(4,5); extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); @@ -101,17 +132,25 @@ extern void error_meta (rich_location *, const diagnostic_metadata &, extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3) ATTRIBUTE_NORETURN; /* Pass one of the OPT_W* from options.h as the second parameter. */ -extern bool pedwarn (location_t, int, const char *, ...) +extern bool pedwarn (location_t, + diagnostic_option_id, + const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); -extern bool pedwarn (rich_location *, int, const char *, ...) +extern bool pedwarn (rich_location *, + diagnostic_option_id, + const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); extern bool permerror (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); extern bool permerror (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); -extern bool permerror_opt (location_t, int, const char *, ...) +extern bool permerror_opt (location_t, + diagnostic_option_id, + const char *, ...) + ATTRIBUTE_GCC_DIAG(3,4); +extern bool permerror_opt (rich_location *, + diagnostic_option_id, + const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); -extern bool permerror_opt (rich_location *, int, const char *, - ...) ATTRIBUTE_GCC_DIAG(3,4); extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); extern void sorry_at (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); @@ -120,16 +159,23 @@ extern void inform_n (location_t, unsigned HOST_WIDE_INT, const char *, const char *, ...) ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5); extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); -extern bool emit_diagnostic (diagnostic_t, location_t, int, +extern bool emit_diagnostic (diagnostic_t, + location_t, + diagnostic_option_id, const char *, ...) ATTRIBUTE_GCC_DIAG(4,5); -extern bool emit_diagnostic (diagnostic_t, rich_location *, int, +extern bool emit_diagnostic (diagnostic_t, + rich_location *, + diagnostic_option_id, const char *, ...) ATTRIBUTE_GCC_DIAG(4,5); -extern bool emit_diagnostic_valist (diagnostic_t, location_t, int, const char *, - va_list *) ATTRIBUTE_GCC_DIAG (4,0); +extern bool emit_diagnostic_valist (diagnostic_t, + location_t, + diagnostic_option_id, + const char *, va_list *) + ATTRIBUTE_GCC_DIAG (4,0); extern bool emit_diagnostic_valist_meta (diagnostic_t, rich_location *, const diagnostic_metadata *, - int, + diagnostic_option_id, const char *, va_list *) ATTRIBUTE_GCC_DIAG (5,0); extern bool seen_error (void); |