No functional change intended.
gcc/ChangeLog:
* Makefile.in: Replace diagnostic.def with diagnostics/kinds.def.
* config/aarch64/aarch64.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* config/i386/i386-options.cc: Likewise.
* config/s390/s390.cc: Likewise.
* diagnostic-core.h: Replace typedef diagnostic_t with
enum class diagnostics::kind in diagnostics/kinds.h and include
it.
* diagnostic-global-context.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* diagnostic.cc: Likewise.
* diagnostic.h: Likewise.
* diagnostics/buffering.cc: Likewise.
* diagnostics/buffering.h: Likewise.
* diagnostics/context.h: Likewise.
* diagnostics/diagnostic-info.h: Likewise.
* diagnostics/html-sink.cc: Likewise.
* diagnostic.def: Move to...
* diagnostics/kinds.def: ...here and update for diagnostic_t
becoming enum class diagnostics::kind.
* diagnostics/kinds.h: New file, based on material in
diagnostic-core.h.
* diagnostics/lazy-paths.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* diagnostics/option-classifier.cc: Likewise.
* diagnostics/option-classifier.h: Likewise.
* diagnostics/output-spec.h: Likewise.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/selftest-context.cc: Likewise.
* diagnostics/selftest-context.h: Likewise.
* diagnostics/sink.h: Likewise.
* diagnostics/source-printing.cc: Likewise.
* diagnostics/text-sink.cc: Likewise.
* diagnostics/text-sink.h: Likewise.
* gcc.cc: Likewise.
* libgdiagnostics.cc: Likewise.
* lto-wrapper.cc: Likewise.
* opts-common.cc: Likewise.
* opts-diagnostic.h: Likewise.
* opts.cc: Likewise.
* rtl-error.cc: Likewise.
* substring-locations.cc: Likewise.
* toplev.cc: Likewise.
gcc/ada/ChangeLog:
* gcc-interface/trans.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
gcc/analyzer/ChangeLog:
* pending-diagnostic.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* program-point.cc: Likewise.
gcc/c-family/ChangeLog:
* c-common.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* c-format.cc: Likewise.
* c-lex.cc: Likewise.
* c-opts.cc: Likewise.
* c-pragma.cc: Likewise.
* c-warn.cc: Likewise.
gcc/c/ChangeLog:
* c-errors.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* c-parser.cc: Likewise.
* c-typeck.cc: Likewise.
gcc/cobol/ChangeLog:
* util.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
gcc/cp/ChangeLog:
* call.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* constexpr.cc: Likewise.
* cp-tree.h: Likewise.
* decl.cc: Likewise.
* error.cc: Likewise.
* init.cc: Likewise.
* method.cc: Likewise.
* module.cc: Likewise.
* parser.cc: Likewise.
* pt.cc: Likewise.
* semantics.cc: Likewise.
* typeck.cc: Likewise.
* typeck2.cc: Likewise.
gcc/d/ChangeLog:
* d-diagnostic.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
gcc/fortran/ChangeLog:
* cpp.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* error.cc: Likewise.
* options.cc: Likewise.
gcc/jit/ChangeLog:
* dummy-frontend.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
gcc/m2/ChangeLog:
* gm2-gcc/m2linemap.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* gm2-gcc/rtegraph.cc: Likewise.
gcc/rust/ChangeLog:
* backend/rust-tree.cc: Update for diagnostic_t becoming
enum class diagnostics::kind.
* backend/rust-tree.h: Likewise.
* resolve/rust-ast-resolve-expr.cc: Likewise.
* resolve/rust-ice-finalizer.cc: Likewise.
* resolve/rust-ice-finalizer.h: Likewise.
* resolve/rust-late-name-resolver-2.0.cc: Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Update for
diagnostic_t becoming enum class diagnostics::kind.
* gcc.dg/plugin/expensive_selftests_plugin.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.
* lib/gcc-dg.exp: Likewise.
libcpp/ChangeLog:
* internal.h: Update comment for diagnostic_t becoming
enum class diagnostics::kind.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
PRETTY_PRINT_H = pretty-print.h $(INPUT_H) $(OBSTACK_H) wide-int-print.h
TREE_PRETTY_PRINT_H = tree-pretty-print.h $(PRETTY_PRINT_H)
GIMPLE_PRETTY_PRINT_H = gimple-pretty-print.h $(TREE_PRETTY_PRINT_H)
-DIAGNOSTIC_CORE_H = diagnostic-core.h $(INPUT_H) bversion.h diagnostic.def
+DIAGNOSTIC_CORE_H = diagnostic-core.h $(INPUT_H) bversion.h diagnostics/kinds.def
DIAGNOSTIC_H = diagnostic.h $(DIAGNOSTIC_CORE_H) $(PRETTY_PRINT_H)
C_PRETTY_PRINT_H = c-family/c-pretty-print.h $(PRETTY_PRINT_H) \
$(C_COMMON_H) $(TREE_H)
const location_t location = input_location;
struct cl_option_handlers handlers;
unsigned int option_index;
- diagnostic_t kind;
+ enum diagnostics::kind kind;
bool imply;
gnat_temp = First (Pragma_Argument_Associations (gnat_node));
switch (id)
{
case Pragma_Warning_As_Error:
- kind = DK_ERROR;
+ kind = diagnostics::kind::error;
imply = false;
break;
case Pragma_Warnings:
- kind = DK_WARNING;
+ kind = diagnostics::kind::warning;
imply = true;
break;
switch (Chars (Expression (gnat_temp)))
{
case Name_Off:
- kind = DK_IGNORED;
+ kind = diagnostics::kind::ignored;
break;
case Name_On:
- kind = DK_WARNING;
+ kind = diagnostics::kind::warning;
break;
default:
gnat_expr = Empty;
/* For pragma Warnings (Off), we save the current state... */
- if (kind == DK_IGNORED)
+ if (kind == diagnostics::kind::ignored)
diagnostic_push_diagnostics (global_dc, location);
/* ...so that, for pragma Warnings (On), we do not enable all
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- const bool result = emit_diagnostic_valist_meta (DK_WARNING,
+ const bool result = emit_diagnostic_valist_meta (diagnostics::kind::warning,
&m_rich_loc, &m_metadata,
pd.get_controlling_option (),
gmsgid, &ap);
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- emit_diagnostic_valist_meta (DK_NOTE,
+ emit_diagnostic_valist_meta (diagnostics::kind::note,
&m_rich_loc, &m_metadata,
pd.get_controlling_option (),
gmsgid, &ap);
gcc_rich_location richloc (stmt->location);
diagnostics::source_print_policy source_policy (tmp_dc);
gcc_assert (pp);
- source_policy.print (*pp, richloc, DK_ERROR, nullptr);
+ source_policy.print (*pp, richloc, diagnostics::kind::error, nullptr);
pp_string (pp, pp_formatted_text (tmp_dc.get_reference_printer ()));
}
const char *msg, va_list *ap)
{
diagnostic_info diagnostic;
- diagnostic_t dlevel;
+ enum diagnostics::kind dlevel;
bool save_warn_system_headers = global_dc->m_warn_system_headers;
bool ret;
case CPP_DL_WARNING:
if (flag_no_output)
return false;
- dlevel = DK_WARNING;
+ dlevel = diagnostics::kind::warning;
break;
case CPP_DL_PEDWARN:
if (flag_no_output && !flag_pedantic_errors)
return false;
- dlevel = DK_PEDWARN;
+ dlevel = diagnostics::kind::pedwarn;
break;
case CPP_DL_ERROR:
- dlevel = DK_ERROR;
+ dlevel = diagnostics::kind::error;
break;
case CPP_DL_ICE:
- dlevel = DK_ICE;
+ dlevel = diagnostics::kind::ice;
break;
case CPP_DL_NOTE:
- dlevel = DK_NOTE;
+ dlevel = diagnostics::kind::note;
break;
case CPP_DL_FATAL:
- dlevel = DK_FATAL;
+ dlevel = diagnostics::kind::fatal;
break;
default:
gcc_unreachable ();
diagnostics::selftest::test_context dc;
diagnostic_show_locus (&dc,
dc.m_source_printing,
- &richloc, DK_ERROR, dc.get_reference_printer ());
+ &richloc,
+ diagnostics::kind::error,
+ dc.get_reference_printer ());
if (c_dialect_cxx ())
/* "char*", without a space. */
ASSERT_STREQ (" printf (\"msg: %i\\n\", msg);\n"
&& (flags & CPP_N_WIDTH) != CPP_N_LARGE)
emit_diagnostic
((c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99)
- ? DK_PEDWARN : DK_WARNING,
+ ? diagnostics::kind::pedwarn : diagnostics::kind::warning,
input_location, OPT_Wlong_long,
(flags & CPP_N_UNSIGNED)
? "integer constant is too large for %<unsigned long%> type"
static void
c_diagnostic_text_finalizer (diagnostics::text_sink &text_output,
const diagnostic_info *diagnostic,
- diagnostic_t)
+ enum diagnostics::kind)
{
pretty_printer *const pp = text_output.get_printer ();
char *saved_prefix = pp_take_prefix (pp);
PK_IGNORED_ATTRIBUTES,
PK_DIAGNOSTIC,
} pd_kind;
- diagnostic_t diagnostic_kind;
+ enum diagnostics::kind diagnostic_kind;
const char *kind_str;
const char *option_str;
bool own_option_str;
valid = false;
loc_kind = loc_option = UNKNOWN_LOCATION;
pd_kind = PK_INVALID;
- diagnostic_kind = DK_UNSPECIFIED;
+ diagnostic_kind = diagnostics::kind::unspecified;
kind_str = option_str = nullptr;
own_option_str = false;
}
kind_str = kind_string;
pd_kind = PK_INVALID;
- diagnostic_kind = DK_UNSPECIFIED;
+ diagnostic_kind = diagnostics::kind::unspecified;
if (strcmp (kind_str, "push") == 0)
pd_kind = PK_PUSH;
else if (strcmp (kind_str, "pop") == 0)
else if (strcmp (kind_str, "error") == 0)
{
pd_kind = PK_DIAGNOSTIC;
- diagnostic_kind = DK_ERROR;
+ diagnostic_kind = diagnostics::kind::error;
}
else if (strcmp (kind_str, "warning") == 0)
{
pd_kind = PK_DIAGNOSTIC;
- diagnostic_kind = DK_WARNING;
+ diagnostic_kind = diagnostics::kind::warning;
}
else if (strcmp (kind_str, "ignored") == 0)
{
pd_kind = PK_DIAGNOSTIC;
- diagnostic_kind = DK_IGNORED;
+ diagnostic_kind = diagnostics::kind::ignored;
}
}
what we used to do here before and changing it breaks e.g.
PR69543 and PR69558. */
control_warning_option (option_index, (int) data.diagnostic_kind,
- arg, data.diagnostic_kind != DK_IGNORED,
+ arg,
+ data.diagnostic_kind != diagnostics::kind::ignored,
input_location, lang_mask, &handlers,
&global_options, &global_options_set,
global_dc);
op1 = TREE_OPERAND (op1, 0);
auto_diagnostic_group d;
- diagnostic_t kind = DK_WARNING;
+ enum diagnostics::kind kind = diagnostics::kind::warning;
const char *msg;
if (c_dialect_cxx () && cxx_dialect >= cxx20)
{
if (cxx_dialect >= cxx26)
{
msg = G_("comparison between two arrays is not allowed in C++26");
- kind = DK_PERMERROR;
+ kind = diagnostics::kind::permerror;
}
else
msg = G_("comparison between two arrays is deprecated in C++20");
{
diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
(pedantic && !flag_isoc2y)
- ? DK_PEDWARN : DK_WARNING);
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::warning);
diagnostic.m_option_id = OPT_Wc23_c2y_compat;
warned = diagnostic_report_diagnostic (global_dc, &diagnostic);
}
/* For -pedantic outside C2Y, issue a pedwarn. */
else if (pedantic && !flag_isoc2y)
{
- diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_PEDWARN);
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
+ diagnostics::kind::pedwarn);
diagnostic.m_option_id = option_id;
warned = diagnostic_report_diagnostic (global_dc, &diagnostic);
}
{
diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
(pedantic && !flag_isoc23)
- ? DK_PEDWARN : DK_WARNING);
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::warning);
if (option_id == OPT_Wpedantic)
diagnostic.m_option_id = OPT_Wc11_c23_compat;
else
/* For -pedantic outside C23, issue a pedwarn. */
else if (pedantic && !flag_isoc23)
{
- diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_PEDWARN);
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
+ diagnostics::kind::pedwarn);
diagnostic.m_option_id = option_id;
warned = diagnostic_report_diagnostic (global_dc, &diagnostic);
}
{
diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
(pedantic && !flag_isoc11)
- ? DK_PEDWARN : DK_WARNING);
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::warning);
diagnostic.m_option_id = OPT_Wc99_c11_compat;
warned = diagnostic_report_diagnostic (global_dc, &diagnostic);
}
/* For -pedantic outside C11, issue a pedwarn. */
else if (pedantic && !flag_isoc11)
{
- diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_PEDWARN);
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
+ diagnostics::kind::pedwarn);
diagnostic.m_option_id = option_id;
warned = diagnostic_report_diagnostic (global_dc, &diagnostic);
}
{
diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
(pedantic && !flag_isoc99)
- ? DK_PEDWARN : DK_WARNING);
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::warning);
diagnostic.m_option_id = option_id;
diagnostic_report_diagnostic (global_dc, &diagnostic);
warned = true;
{
diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
(pedantic && !flag_isoc99)
- ? DK_PEDWARN : DK_WARNING);
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::warning);
diagnostic.m_option_id = OPT_Wc90_c99_compat;
diagnostic_report_diagnostic (global_dc, &diagnostic);
}
/* For -pedantic outside C99, issue a pedwarn. */
else if (pedantic && !flag_isoc99)
{
- diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_PEDWARN);
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
+ diagnostics::kind::pedwarn);
diagnostic.m_option_id = option_id;
diagnostic_report_diagnostic (global_dc, &diagnostic);
warned = true;
if (msg == NULL)
msg = _("<message unknown at compile time>");
}
+ const enum diagnostics::kind diag_kind = (severity_fatal
+ ? diagnostics::kind::error
+ : diagnostics::kind::warning);
if (msg)
- emit_diagnostic (severity_fatal ? DK_ERROR : DK_WARNING, loc, 0,
+ emit_diagnostic (diag_kind, loc, 0,
"%<pragma omp error%> encountered: %s", msg);
else
- emit_diagnostic (severity_fatal ? DK_ERROR : DK_WARNING, loc, 0,
+ emit_diagnostic (diag_kind, loc, 0,
"%<pragma omp error%> encountered");
return false;
}
else
{
int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
- diagnostic_t kind = DK_PERMERROR;
+ enum diagnostics::kind kind = diagnostics::kind::permerror;
if (!flag_isoc99)
/* This downgrade to a warning ensures that -std=gnu89
-pedantic-errors does not flag these mismatches between
- builtins as errors (as DK_PERMERROR would). ISO C99
- and later do not have implicit function declarations,
+ builtins as errors (as diagnostics::kind::permerror would)
+ ISO C99 and later do not have implicit function declarations,
so the mismatch cannot occur naturally there. */
- kind = bltin1 && bltin2 ? DK_WARNING : DK_PEDWARN;
+ kind = (bltin1 && bltin2
+ ? diagnostics::kind::warning
+ : diagnostics::kind::pedwarn);
if (emit_diagnostic (kind, colon_loc, OPT_Wincompatible_pointer_types,
"pointer type mismatch "
"in conditional expression"))
/* The gmsgid may be a format string with %< and %>. */
va_list ap;
va_start (ap, gmsgid);
- bool warned = emit_diagnostic_valist (DK_ERROR, loc, -1, gmsgid, &ap);
+ bool warned = emit_diagnostic_valist (diagnostics::kind::error,
+ loc, -1, gmsgid, &ap);
va_end (ap);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
static bool ATTRIBUTE_GCC_DIAG (3,0)
pedwarn_permerror_init (location_t loc, int opt, const char *gmsgid,
- va_list *ap, diagnostic_t kind)
+ va_list *ap, enum diagnostics::kind kind)
{
/* Use the location where a macro was expanded rather than where
it was defined to make sure macros defined in system headers
{
va_list ap;
va_start (ap, gmsgid);
- bool warned = pedwarn_permerror_init (loc, opt, gmsgid, &ap, DK_PEDWARN);
+ bool warned = pedwarn_permerror_init (loc, opt, gmsgid, &ap,
+ diagnostics::kind::pedwarn);
va_end (ap);
return warned;
}
{
va_list ap;
va_start (ap, gmsgid);
- bool warned = pedwarn_permerror_init (loc, opt, gmsgid, &ap, DK_PERMERROR);
+ bool warned = pedwarn_permerror_init (loc, opt, gmsgid, &ap,
+ diagnostics::kind::permerror);
va_end (ap);
return warned;
}
&& valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE)
{
no_warning = true;
- if (emit_diagnostic (flag_isoc99 ? DK_PERMERROR : DK_WARNING,
+ if (emit_diagnostic (flag_isoc99
+ ? diagnostics::kind::permerror
+ : diagnostics::kind::warning,
loc, OPT_Wreturn_mismatch,
"%<return%> with no value,"
" in function returning non-void"))
va_start (ap, gmsgid);
rich_location richloc (line_table, token_location);
/*bool ret =*/ global_dc->diagnostic_impl (&richloc, nullptr, option_zero,
- gmsgid, &ap, DK_ERROR);
+ gmsgid, &ap,
+ diagnostics::kind::error);
va_end (ap);
}
va_start (ap, gmsgid); \
rich_location richloc (line_table, token_location); \
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_zero, \
- gmsgid, &ap, DK_ERROR); \
+ gmsgid, &ap, \
+ diagnostics::kind::error); \
va_end (ap); \
global_dc->end_group();
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, token_location);
- auto ret = emit_diagnostic_valist( DK_WARNING, token_location,
+ auto ret = emit_diagnostic_valist( diagnostics::kind::warning,
+ token_location,
option_zero, gmsgid, &ap );
va_end (ap);
return ret;
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- /*auto ret = */emit_diagnostic_valist( DK_ERROR, token_location,
+ /*auto ret = */emit_diagnostic_valist( diagnostics::kind::error,
+ token_location,
option_zero, gmsgid, &ap );
va_end (ap);
}
nullptr,
option_zero,
gmsgid,
- &ap, DK_ERROR);
+ &ap, diagnostics::kind::error);
va_end (ap);
global_dc->end_group();
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- auto ret = emit_diagnostic_valist( DK_WARNING, token_location,
+ auto ret = emit_diagnostic_valist( diagnostics::kind::warning, token_location,
option_zero, gmsgid, &ap );
va_end (ap);
return ret;
auto_diagnostic_group d;
va_list ap;
va_start(ap, gmsgid);
- emit_diagnostic_valist( DK_ICE, token_location, option_zero, gmsgid, &ap );
+ emit_diagnostic_valist( diagnostics::kind::ice,
+ token_location, option_zero, gmsgid, &ap );
va_end(ap);
abort(); // This unnecessary statement is needed so that [[noreturn]]
// // doesn't cause a warning.
auto_diagnostic_group d;
va_list ap;
va_start(ap, gmsgid);
- emit_diagnostic_valist( DK_SORRY, token_location, option_zero, gmsgid, &ap );
+ emit_diagnostic_valist( diagnostics::kind::sorry,
+ token_location, option_zero, gmsgid, &ap );
va_end(ap);
}
auto_diagnostic_group d;
va_list ap;
va_start(ap, gmsgid);
- emit_diagnostic_valist( DK_SORRY, token_location, option_zero, gmsgid, &ap );
+ emit_diagnostic_valist( diagnostics::kind::sorry,
+ token_location, option_zero, gmsgid, &ap );
va_end(ap);
}
auto_diagnostic_group d;
va_list ap;
va_start(ap, gmsgid);
- emit_diagnostic_valist( DK_SORRY, token_location, option_zero, gmsgid, &ap );
+ emit_diagnostic_valist( diagnostics::kind::sorry,
+ token_location, option_zero, gmsgid, &ap );
va_end(ap);
}
verify_format(gmsgid);
va_list ap;
va_start(ap, fmt);
- emit_diagnostic_valist( DK_FATAL, token_location, option_zero, gmsgid, &ap );
+ emit_diagnostic_valist( diagnostics::kind::fatal,
+ token_location, option_zero, gmsgid, &ap );
va_end(ap);
}
#pragma GCC diagnostic pop
auto_diagnostic_group d;
va_list ap;
va_start(ap, gmsgid);
- emit_diagnostic_valist( DK_FATAL, token_location, option_zero, gmsgid, &ap );
+ emit_diagnostic_valist( diagnostics::kind::fatal,
+ token_location, option_zero, gmsgid, &ap );
va_end(ap);
}
if (valid)
{
set_option (&global_options, NULL, p_attr->opt_num, value,
- NULL, DK_UNSPECIFIED, input_location,
- global_dc);
+ NULL,
+ static_cast<int> (diagnostics::kind::unspecified),
+ input_location, global_dc);
}
else
{
arg_ok = opt_enum_arg_to_value (opt, p + opt_len, &value, CL_TARGET);
if (arg_ok)
set_option (opts, enum_opts_set, opt, value,
- p + opt_len, DK_UNSPECIFIED, input_location,
+ p + opt_len,
+ static_cast<int> (diagnostics::kind::unspecified),
+ input_location,
global_dc);
else
{
generate_option (opt, NULL, value, CL_TARGET, &decoded);
s390_handle_option (opts, new_opts_set, &decoded, input_location);
set_option (opts, new_opts_set, opt, value,
- p + opt_len, DK_UNSPECIFIED, input_location,
- global_dc);
+ p + opt_len,
+ static_cast<int> (diagnostics::kind::unspecified),
+ input_location, global_dc);
}
else
{
arg_ok = opt_enum_arg_to_value (opt, p + opt_len, &value, CL_TARGET);
if (arg_ok)
set_option (opts, new_opts_set, opt, value,
- p + opt_len, DK_UNSPECIFIED, input_location,
- global_dc);
+ p + opt_len,
+ static_cast<int> (diagnostics::kind::unspecified),
+ input_location, global_dc);
else
{
error ("attribute %<target%> argument %qs is unknown", orig_p);
bool, tree, tree, int, struct z_candidate **,
tsubst_flags_t);
static conversion *merge_conversion_sequences (conversion *, conversion *);
-static tree build_temp (tree, tree, int, diagnostic_t *, tsubst_flags_t);
+static tree build_temp (tree, tree, int, enum diagnostics::kind *,
+ tsubst_flags_t);
static conversion *build_identity_conv (tree, tree);
static inline bool conv_binds_to_array_of_unknown_bound (conversion *);
static bool conv_is_prvalue (conversion *);
types when the enumeration is still being defined. */;
else if (complain & (cxx_dialect >= cxx26
? tf_warning_or_error : tf_warning))
- emit_diagnostic (cxx_dialect >= cxx26 ? DK_PEDWARN : DK_WARNING,
+ emit_diagnostic ((cxx_dialect >= cxx26
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::warning),
loc, OPT_Wenum_compare, "enumerated mismatch "
"in conditional expression: %qT vs %qT",
arg2_type, arg3_type);
&& (complain & tf_warning_or_error) == 0)
result = error_mark_node;
else if (cxx_dialect >= cxx26 || (complain & tf_warning))
- emit_diagnostic (cxx_dialect >= cxx26
- ? DK_PEDWARN : DK_WARNING,
+ emit_diagnostic ((cxx_dialect >= cxx26
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::warning),
loc, OPT_Wenum_compare,
"comparison between %q#T and %q#T",
arg1_type, arg2_type);
static tree
build_temp (tree expr, tree type, int flags,
- diagnostic_t *diagnostic_kind, tsubst_flags_t complain)
+ enum diagnostics::kind *diagnostic_kind, tsubst_flags_t complain)
{
int savew, savee;
- *diagnostic_kind = DK_UNSPECIFIED;
+ *diagnostic_kind = diagnostics::kind::unspecified;
/* If the source is a packed field, calling the copy constructor will require
binding the field to the reference parameter to the copy constructor, and
expr = build_special_member_call (NULL_TREE, complete_ctor_identifier,
&args, type, flags, complain);
if (warningcount + werrorcount > savew)
- *diagnostic_kind = DK_WARNING;
+ *diagnostic_kind = diagnostics::kind::warning;
else if (errorcount > savee)
- *diagnostic_kind = DK_ERROR;
+ *diagnostic_kind = diagnostics::kind::error;
return expr;
}
bool nested_p, tsubst_flags_t complain)
{
tree totype = convs->type;
- diagnostic_t diag_kind;
+ enum diagnostics::kind diag_kind;
int flags;
location_t loc = cp_expr_loc_or_input_loc (expr);
const bool stub_object_p = is_stub_object (expr);
if (convs->copy_init_p)
flags |= LOOKUP_ONLYCONVERTING;
expr = build_temp (expr, totype, flags, &diag_kind, complain);
- if (diag_kind && complain)
+ if (diag_kind != diagnostics::kind::unspecified && complain)
{
auto_diagnostic_group d;
maybe_print_user_conv_context (convs);
if (!constexpr_fundef_p)
{
/* Report an error that cannot be suppressed. */
- diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_ERROR);
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
+ diagnostics::kind::error);
ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
}
else if (warn_invalid_constexpr)
{
diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
- cxx_dialect < cxx23 ? DK_PEDWARN : DK_WARNING);
+ (cxx_dialect < cxx23
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::warning));
diagnostic.m_option_id = OPT_Winvalid_constexpr;
ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
}
/* in typeck2.cc */
extern void require_complete_eh_spec_types (tree, tree);
extern bool cxx_incomplete_type_diagnostic (location_t, const_tree,
- const_tree, diagnostic_t);
+ const_tree, enum diagnostics::kind);
inline location_t
loc_or_input_loc (location_t loc)
{
inline bool
cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
- diagnostic_t diag_kind)
+ enum diagnostics::kind diag_kind)
{
return cxx_incomplete_type_diagnostic (cp_expr_loc_or_input_loc (value),
value, type, diag_kind);
inline void
cxx_incomplete_type_error (const_tree value, const_tree type)
{
- cxx_incomplete_type_diagnostic (value, type, DK_ERROR);
+ cxx_incomplete_type_diagnostic (value, type, diagnostics::kind::error);
}
extern void cxx_incomplete_type_inform (const_tree);
static void expand_static_init (tree, tree);
static location_t smallest_type_location (const cp_decl_specifier_seq*);
static bool identify_goto (tree, location_t, const location_t *,
- diagnostic_t, bool);
+ enum diagnostics::kind, bool);
/* The following symbols are subsumed in the cp_global_trees array, and
listed here individually for documentation purposes.
static bool
identify_goto (tree decl, location_t loc, const location_t *locus,
- diagnostic_t diag_kind, bool computed)
+ enum diagnostics::kind diag_kind, bool computed)
{
if (computed)
- diag_kind = DK_WARNING;
+ diag_kind = diagnostics::kind::warning;
bool complained
= emit_diagnostic (diag_kind, loc, 0,
decl ? G_("jump to label %qD")
if (exited_omp)
{
- complained = identify_goto (decl, input_location, locus, DK_ERROR,
+ complained = identify_goto (decl, input_location, locus,
+ diagnostics::kind::error,
computed);
if (complained)
inform (input_location, " exits OpenMP structured block");
if (!identified)
{
- complained = identify_goto (decl, input_location, locus, DK_ERROR,
+ complained = identify_goto (decl, input_location, locus,
+ diagnostics::kind::error,
computed);
identified = 2;
}
if (inf)
{
if (identified < 2)
- complained = identify_goto (decl, input_location, locus, DK_ERROR,
+ complained = identify_goto (decl, input_location, locus,
+ diagnostics::kind::error,
computed);
identified = 2;
if (complained)
if (!vec_safe_is_empty (computed))
{
if (!identified)
- complained = identify_goto (decl, input_location, locus, DK_ERROR,
+ complained = identify_goto (decl, input_location, locus,
+ diagnostics::kind::error,
computed);
identified = 2;
if (complained)
|| ent->in_omp_scope || ent->in_stmt_expr
|| !vec_safe_is_empty (ent->bad_decls))
{
- diagnostic_t diag_kind = DK_PERMERROR;
+ enum diagnostics::kind diag_kind = diagnostics::kind::permerror;
if (ent->in_try_scope || ent->in_catch_scope || ent->in_constexpr_if
|| ent->in_consteval_if || ent->in_transaction_scope
|| ent->in_omp_scope || ent->in_stmt_expr)
- diag_kind = DK_ERROR;
+ diag_kind = diagnostics::kind::error;
complained = identify_goto (decl, DECL_SOURCE_LOCATION (decl),
&input_location, diag_kind, computed);
- identified = 1 + (diag_kind == DK_ERROR);
+ identified = 1 + (diag_kind == diagnostics::kind::error);
}
FOR_EACH_VEC_SAFE_ELT (ent->bad_decls, ix, bad)
if (identified == 1)
{
complained = identify_goto (decl, DECL_SOURCE_LOCATION (decl),
- &input_location, DK_ERROR, computed);
+ &input_location,
+ diagnostics::kind::error,
+ computed);
identified = 2;
}
if (complained)
{
complained = identify_goto (decl,
DECL_SOURCE_LOCATION (decl),
- &input_location, DK_ERROR,
+ &input_location,
+ diagnostics::kind::error,
computed);
identified = 2;
}
{
complained
= identify_goto (decl, DECL_SOURCE_LOCATION (decl),
- &input_location, DK_ERROR, computed);
+ &input_location, diagnostics::kind::error,
+ computed);
identified = 2;
}
if (complained)
{
complained
= identify_goto (decl, DECL_SOURCE_LOCATION (decl),
- &input_location, DK_ERROR, computed);
+ &input_location, diagnostics::kind::error,
+ computed);
identified = 2;
}
if (complained)
t && t != void_list_node; t = TREE_CHAIN (t))
if (TREE_PURPOSE (t))
{
- diagnostic_t diag_kind = DK_PERMERROR;
+ enum diagnostics::kind diag_kind = diagnostics::kind::permerror;
/* For templates, mark the default argument as erroneous and give a
hard error. */
if (processing_template_decl)
{
- diag_kind = DK_ERROR;
+ diag_kind = diagnostics::kind::error;
TREE_PURPOSE (t) = error_mark_node;
}
if (!has_errored)
compatibility. */
if (processing_template_decl
&& CLASS_TYPE_P (basetype) && TYPE_BEING_DEFINED (basetype))
- cxx_incomplete_type_diagnostic (NULL_TREE, basetype, DK_PEDWARN);
+ cxx_incomplete_type_diagnostic (NULL_TREE, basetype,
+ diagnostics::kind::pedwarn);
if (!dependent_type_p (basetype)
&& !complete_type_or_else (basetype, NULL))
/* An incomplete type. Remove it from the list. */
cp_adjust_diagnostic_info (diagnostics::context *context,
diagnostic_info *diagnostic)
{
- if (diagnostic->m_kind == DK_ERROR)
+ if (diagnostic->m_kind == diagnostics::kind::error)
if (tree tmpl = get_current_template ())
{
diagnostic->m_option_id = OPT_Wtemplate_body;
if (context->m_permissive)
- diagnostic->m_kind = DK_WARNING;
+ diagnostic->m_kind = diagnostics::kind::warning;
bool existed;
location_t &error_loc
diagnostic_show_locus (&m_text_output.get_context (),
m_text_output.get_source_printing_options (),
&rich_loc,
- DK_NOTE, pp);
+ diagnostics::kind::note, pp);
pp_set_prefix (pp, saved_prefix);
}
}
diagnostic_show_locus (&m_text_output.get_context (),
m_text_output.get_source_printing_options (),
&rich_loc,
- DK_NOTE, pp);
+ diagnostics::kind::note, pp);
pp_set_prefix (pp, saved_prefix);
}
}
va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
- (cxx_dialect == cxx98) ? DK_PEDWARN : DK_WARNING);
+ (cxx_dialect == cxx98
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::warning));
diagnostic.m_option_id = option_id;
ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
va_end (ap);
"possible problem detected in invocation of "
"operator %<delete []%>"))
{
- cxx_incomplete_type_diagnostic (base, type, DK_WARNING);
+ cxx_incomplete_type_diagnostic (base, type,
+ diagnostics::kind::warning);
inform (loc, "neither the destructor nor the "
"class-specific operator %<delete []%> will be called, "
"even if they are declared when the class is defined");
"possible problem detected in invocation of "
"%<operator delete%>"))
{
- cxx_incomplete_type_diagnostic (addr, type, DK_WARNING);
+ cxx_incomplete_type_diagnostic (addr, type,
+ diagnostics::kind::warning);
inform (loc,
"neither the destructor nor the class-specific "
"%<operator delete%> will be called, even if "
if (!DECL_OVERLOADED_OPERATOR_IS (fn, SPACESHIP_EXPR)
&& !same_type_p (TREE_TYPE (TREE_TYPE (fn)), boolean_type_node))
{
- diagnostic_t kind = DK_UNSPECIFIED;
+ enum diagnostics::kind kind = diagnostics::kind::unspecified;
int opt = 0;
if (is_auto (TREE_TYPE (fn)))
- kind = DK_PEDWARN;
+ kind = diagnostics::kind::pedwarn;
else
- kind = DK_ERROR;
+ kind = diagnostics::kind::error;
emit_diagnostic (kind, loc, opt,
"defaulted %qD must return %<bool%>", fn);
- if (kind == DK_ERROR)
+ if (kind == diagnostics::kind::error)
ok = false;
}
the program is ill-formed" */
|| !TYPE_REF_P (parmtype)));
/* Decide if we want to emit a pedwarn, error, or a warning. */
- diagnostic_t diag_kind;
+ enum diagnostics::kind diag_kind;
int opt;
if (illformed_p)
{
- diag_kind = DK_ERROR;
+ diag_kind = diagnostics::kind::error;
opt = 0;
}
else
{
- diag_kind = cxx_dialect >= cxx20 ? DK_WARNING : DK_PEDWARN;
+ diag_kind = (cxx_dialect >= cxx20
+ ? diagnostics::kind::warning
+ : diagnostics::kind::pedwarn);
opt = OPT_Wdefaulted_function_deleted;
}
/* Don't warn for template instantiations. */
- if (DECL_TEMPLATE_INSTANTIATION (fn) && diag_kind == DK_WARNING)
+ if (DECL_TEMPLATE_INSTANTIATION (fn)
+ && diag_kind == diagnostics::kind::warning)
return;
const char *wmsg;
/* Return the prefix to use for dumping a #pragma diagnostic change to DK. */
static const char *
-dk_string (diagnostic_t dk)
+dk_string (enum diagnostics::kind dk)
{
- gcc_assert (dk > DK_UNSPECIFIED && dk < DK_LAST_DIAGNOSTIC_KIND);
- if (dk == DK_IGNORED)
- /* diagnostic.def has an empty string for ignored. */
+ gcc_assert (dk > diagnostics::kind::unspecified
+ && dk < diagnostics::kind::last_diagnostic_kind);
+ if (dk == diagnostics::kind::ignored)
+ /* diagnostics/kinds.def has an empty string for ignored. */
return "ignored: ";
else
- return get_diagnostic_kind_text (dk);
+ return diagnostics::get_text_for_kind (dk);
}
/* Dump one #pragma GCC diagnostic entry. */
static bool
-dump_dc_change (unsigned index, unsigned opt, diagnostic_t dk)
+dump_dc_change (unsigned index, unsigned opt, enum diagnostics::kind dk)
{
- if (dk == DK_POP)
+ if (dk == diagnostics::kind::pop)
return dump (" Index %u: pop from %d", index, opt);
else
return dump (" Index %u: %s%s", index, dk_string (dk),
unsigned len = changes.length ();
/* We don't want to write out any entries that came from one of our imports.
- But then we need to adjust the total, and change DK_POP targets to match
- the index in our actual output. So remember how many lines we had skipped
- at each step, where -1 means this line itself is skipped. */
+ But then we need to adjust the total, and change diagnostics::kind::pop
+ targets to match the index in our actual output. So remember how many
+ lines we had skipped at each step, where -1 means this line itself
+ is skipped. */
int skips = 0;
auto_vec<int> skips_at (len);
skips_at.safe_grow (len);
if (sec.streaming_p ())
{
unsigned opt = c.option;
- if (c.kind == DK_POP)
+ if (c.kind == diagnostics::kind::pop)
opt -= skips_at[opt];
sec.u (opt);
- sec.u (c.kind);
+ sec.u (static_cast<unsigned> (c.kind));
dump () && dump_dc_change (i - skips_at[i], opt, c.kind);
}
}
{
location_t loc = read_location (sec);
int opt = sec.u ();
- diagnostic_t kind = (diagnostic_t) sec.u ();
- if (kind == DK_POP)
+ enum diagnostics::kind kind = (enum diagnostics::kind) sec.u ();
+ if (kind == diagnostics::kind::pop)
/* For a pop, opt is the 'changes' index to return to. */
opt += offset;
changes.quick_push ({ loc, opt, kind });
gcc_checking_assert (i >= offset);
const auto &c = changes[i];
- if (c.kind != DK_POP)
+ if (c.kind != diagnostics::kind::pop)
break;
else if (c.option == offset)
{
/* It didn't, so add a pop at its last location to avoid affecting later
imports. */
location_t last_loc = ordinary_locs.first + ordinary_locs.second - 1;
- changes.quick_push ({ last_loc, offset, DK_POP });
+ changes.quick_push ({ last_loc, offset, diagnostics::kind::pop });
dump () && dump (" Adding final pop from index %d", offset);
}
&& (id_equal (suffix_id, "i")
|| id_equal (suffix_id, "if")
|| id_equal (suffix_id, "il")));
- diagnostic_t kind = DK_ERROR;
+ enum diagnostics::kind kind = diagnostics::kind::error;
int opt = 0;
if (i14 && ext)
if (cxlit == error_mark_node)
{
/* No <complex>, so pedwarn and use GNU semantics. */
- kind = DK_PEDWARN;
+ kind = diagnostics::kind::pedwarn;
opt = OPT_Wpedantic;
}
}
"to enable more built-in suffixes");
}
- if (kind == DK_ERROR)
+ if (kind == diagnostics::kind::error)
value = error_mark_node;
else
{
member template. */
static void
-missing_template_diag (location_t loc, diagnostic_t diag_kind = DK_WARNING)
+missing_template_diag (location_t loc,
+ enum diagnostics::kind diag_kind = diagnostics::kind::warning)
{
if (warning_suppressed_at (loc, OPT_Wmissing_template_keyword))
return;
{
/* In a template, be permissive by treating an object expression
of incomplete type as dependent (after a pedwarn). */
- diagnostic_t kind = (processing_template_decl
- && MAYBE_CLASS_TYPE_P (*scope) ? DK_PEDWARN : DK_ERROR);
+ enum diagnostics::kind kind = ((processing_template_decl
+ && MAYBE_CLASS_TYPE_P (*scope))
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::error);
switch (TREE_CODE (*postfix_expression))
{
case IMPLICIT_CONV_EXPR:
case VIEW_CONVERT_EXPR:
case NON_LVALUE_EXPR:
- kind = DK_ERROR;
+ kind = diagnostics::kind::error;
break;
case OVERLOAD:
/* Don't emit any diagnostic for OVERLOADs. */
- kind = DK_IGNORED;
+ kind = diagnostics::kind::ignored;
break;
default:
/* Avoid clobbering e.g. DECLs. */
if (!EXPR_P (*postfix_expression))
- kind = DK_ERROR;
+ kind = diagnostics::kind::error;
break;
}
- if (kind == DK_IGNORED)
+ if (kind == diagnostics::kind::ignored)
return false;
location_t exploc = location_of (*postfix_expression);
cxx_incomplete_type_diagnostic (exploc, *postfix_expression, *scope, kind);
if (!MAYBE_CLASS_TYPE_P (*scope))
return true;
- if (kind == DK_ERROR)
+ if (kind == diagnostics::kind::error)
*scope = *postfix_expression = error_mark_node;
else if (processing_template_decl)
{
diagnostic_push_diagnostics (global_dc, input_location);
diagnostic_classify_diagnostic
(global_dc, OPT_Wconditionally_supported,
- DK_IGNORED, input_location);
+ diagnostics::kind::ignored, input_location);
/* Parse the cast-expression. */
expr = cp_parser_simple_cast_expression (parser);
/* Restore the PEDANTIC flag. */
&& cp_lexer_peek_token (parser->lexer)->type == CPP_TEMPLATE_ID)
{
auto_diagnostic_group d;
- if (emit_diagnostic (cxx_dialect >= cxx20 ? DK_PEDWARN : DK_WARNING,
+ if (emit_diagnostic ((cxx_dialect >= cxx20
+ ? diagnostics::kind::pedwarn
+ : diagnostics::kind::warning),
input_location, OPT_Wtemplate_id_cdtor,
"template-id not allowed for constructor in C++20"))
inform (input_location, "remove the %qs", "< >");
if (msg == NULL)
msg = _("<message unknown at compile time>");
}
+ const enum diagnostics::kind diag_kind = (severity_fatal
+ ? diagnostics::kind::error
+ : diagnostics::kind::warning);
if (msg)
- emit_diagnostic (severity_fatal ? DK_ERROR : DK_WARNING, loc, 0,
+ emit_diagnostic (diag_kind, loc, 0,
"%<pragma omp error%> encountered: %s", msg);
else
- emit_diagnostic (severity_fatal ? DK_ERROR : DK_WARNING, loc, 0,
+ emit_diagnostic (diag_kind, loc, 0,
"%<pragma omp error%> encountered");
return false;
}
/* Be permissive with equivalent alias templates. */
tree u = get_underlying_template (tmpl);
auto_diagnostic_group d;
- diagnostic_t dk = (u == tmpl) ? DK_ERROR : DK_PEDWARN;
+ const enum diagnostics::kind dk = ((u == tmpl)
+ ? diagnostics::kind::error
+ : diagnostics::kind::pedwarn);
bool complained
= emit_diagnostic (dk, input_location, 0,
"alias template deduction only available "
type = complete_type (strip_array_types (type));
if (!COMPLETE_TYPE_P (type)
- && cxx_incomplete_type_diagnostic (NULL_TREE, type, DK_PERMERROR)
+ && cxx_incomplete_type_diagnostic (NULL_TREE, type,
+ diagnostics::kind::permerror)
&& !flag_permissive)
return false;
return true;
else if (!COMPLETE_TYPE_P (type))
{
if (complain & tf_error)
- cxx_incomplete_type_diagnostic (value, type, DK_ERROR);
+ cxx_incomplete_type_diagnostic (value, type, diagnostics::kind::error);
note_failed_type_completion (type, complain);
return NULL_TREE;
}
static void
composite_pointer_error (const op_location_t &location,
- diagnostic_t kind, tree t1, tree t2,
+ enum diagnostics::kind kind, tree t1, tree t2,
composite_pointer_operation operation)
{
switch (operation)
else
{
if (complain & tf_error)
- composite_pointer_error (location, DK_PERMERROR,
+ composite_pointer_error (location, diagnostics::kind::permerror,
t1, t2, operation);
else
return error_mark_node;
TYPE_PTRMEM_CLASS_TYPE (t2)))
{
if (complain & tf_error)
- composite_pointer_error (location, DK_PERMERROR,
+ composite_pointer_error (location, diagnostics::kind::permerror,
t1, t2, operation);
else
return error_mark_node;
else
{
if (complain & tf_error)
- composite_pointer_error (location, DK_ERROR, t1, t2, operation);
+ composite_pointer_error (location, diagnostics::kind::error,
+ t1, t2, operation);
return error_mark_node;
}
}
{
if (TYPE_REF_P (valtype))
/* P2748 made this an error in C++26. */
- emit_diagnostic (cxx_dialect >= cxx26 ? DK_PERMERROR : DK_WARNING,
+ emit_diagnostic ((cxx_dialect >= cxx26
+ ? diagnostics::kind::permerror
+ : diagnostics::kind::warning),
loc, OPT_Wreturn_local_addr,
"returning reference to temporary");
else if (TYPE_PTR_P (valtype))
/* Print an error message for invalid use of an incomplete type.
VALUE is the expression that was used (or 0 if that isn't known)
and TYPE is the type that was invalid. DIAG_KIND indicates the
- type of diagnostic (see diagnostic.def). */
+ type of diagnostic (see diagnostics/kinds.def). */
bool
cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
- const_tree type, diagnostic_t diag_kind)
+ const_tree type,
+ enum diagnostics::kind diag_kind)
{
bool is_decl = false, complained = false;
void
cxx_incomplete_type_error (location_t loc, const_tree value, const_tree type)
{
- cxx_incomplete_type_diagnostic (loc, value, type, DK_ERROR);
+ cxx_incomplete_type_diagnostic (loc, value, type, diagnostics::kind::error);
}
\f
bool ok;
tree core = spec;
bool is_ptr;
- diagnostic_t diag_type = DK_UNSPECIFIED; /* none */
+ enum diagnostics::kind diag_type = diagnostics::kind::unspecified; /* none */
if (spec == error_mark_node)
return list;
and calls. So just give a pedwarn at this point; we will give an
error later if we hit one of those two cases. */
if (!COMPLETE_TYPE_P (complete_type (core)))
- diag_type = DK_PEDWARN; /* pedwarn */
+ diag_type = diagnostics::kind::pedwarn; /* pedwarn */
}
if (ok)
list = tree_cons (NULL_TREE, spec, list);
}
else
- diag_type = DK_ERROR; /* error */
+ diag_type = diagnostics::kind::error; /* error */
- if (diag_type != DK_UNSPECIFIED
+ if (diag_type != diagnostics::kind::unspecified
&& (complain & tf_warning_or_error))
cxx_incomplete_type_diagnostic (NULL_TREE, core, diag_type);
static void ATTRIBUTE_GCC_DIAG(3,0)
d_diagnostic_report_diagnostic (const SourceLoc &loc, int opt,
const char *format, va_list ap,
- diagnostic_t kind, bool verbatim)
+ enum diagnostics::kind kind, bool verbatim)
{
va_list argp;
va_copy (argp, ap);
verrorReport (const SourceLoc loc, const char *format, va_list ap,
ErrorKind kind, const char *prefix1, const char *prefix2)
{
- diagnostic_t diag_kind = DK_UNSPECIFIED;
+ enum diagnostics::kind diag_kind = diagnostics::kind::unspecified;
int opt = 0;
bool verbatim = false;
char *xformat;
if (global.gag && !global.params.v.showGaggedErrors)
return;
- diag_kind = global.gag ? DK_ANACHRONISM : DK_ERROR;
+ diag_kind = (global.gag
+ ? diagnostics::kind::anachronism
+ : diagnostics::kind::error);
}
else if (kind == ErrorKind::warning)
{
if (global.params.useWarnings == DIAGNOSTICerror)
global.warnings++;
- diag_kind = DK_WARNING;
+ diag_kind = diagnostics::kind::warning;
}
else if (kind == ErrorKind::deprecation)
{
}
opt = OPT_Wdeprecated;
- diag_kind = DK_WARNING;
+ diag_kind = diagnostics::kind::warning;
}
else if (kind == ErrorKind::message)
{
- diag_kind = DK_NOTE;
+ diag_kind = diagnostics::kind::note;
verbatim = true;
}
else if (kind == ErrorKind::tip)
if (global.gag)
return;
- diag_kind = DK_DEBUG;
+ diag_kind = diagnostics::kind::debug;
verbatim = true;
}
else
else
gcc_unreachable ();
- d_diagnostic_report_diagnostic (loc, 0, format, ap, DK_NOTE, false);
+ d_diagnostic_report_diagnostic (loc, 0, format, ap, diagnostics::kind::note,
+ false);
}
/* Call this after printing out fatal error messages to clean up and
#define GCC_DIAGNOSTIC_CORE_H
#include "bversion.h"
+#include "diagnostics/kinds.h"
#include "diagnostics/option-id.h"
-/* Constants used to discriminate diagnostics. */
-typedef enum
-{
-#define DEFINE_DIAGNOSTIC_KIND(K, msgid, C) K,
-#include "diagnostic.def"
-#undef DEFINE_DIAGNOSTIC_KIND
- DK_LAST_DIAGNOSTIC_KIND,
- /* This is used for tagging pragma pops in the diagnostic
- classification history chain. */
- DK_POP,
- /* This is used internally to note that a diagnostic is enabled
- without mandating any specific type. */
- DK_ANY,
-} diagnostic_t;
-
/* RAII-style class for grouping related diagnostics within global_dc. */
class auto_diagnostic_group
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,
+extern bool emit_diagnostic (enum diagnostics::kind,
location_t,
diagnostics::option_id,
const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
-extern bool emit_diagnostic (diagnostic_t,
+extern bool emit_diagnostic (enum diagnostics::kind,
rich_location *,
diagnostics::option_id,
const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
-extern bool emit_diagnostic_valist (diagnostic_t,
+extern bool emit_diagnostic_valist (enum diagnostics::kind,
location_t,
diagnostics::option_id,
const char *, va_list *)
ATTRIBUTE_GCC_DIAG (4,0);
-extern bool emit_diagnostic_valist_meta (diagnostic_t,
+extern bool emit_diagnostic_valist_meta (enum diagnostics::kind,
rich_location *,
const diagnostics::metadata *,
diagnostics::option_id,
implying global_dc and taking a variable argument list. */
bool
-emit_diagnostic (diagnostic_t kind,
+emit_diagnostic (enum diagnostics::kind kind,
location_t location,
diagnostics::option_id option_id,
const char *gmsgid, ...)
/* As above, but for rich_location *. */
bool
-emit_diagnostic (diagnostic_t kind,
+emit_diagnostic (enum diagnostics::kind kind,
rich_location *richloc,
diagnostics::option_id option_id,
const char *gmsgid, ...)
/* As above, but taking a variable argument list. */
bool
-emit_diagnostic_valist (diagnostic_t kind,
+emit_diagnostic_valist (enum diagnostics::kind kind,
location_t location,
diagnostics::option_id option_id,
const char *gmsgid, va_list *ap)
/* As above, but with rich_location and metadata. */
bool
-emit_diagnostic_valist_meta (diagnostic_t kind,
+emit_diagnostic_valist_meta (enum diagnostics::kind kind,
rich_location *richloc,
const diagnostics::metadata *metadata,
diagnostics::option_id option_id,
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
- global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_NOTE);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap,
+ diagnostics::kind::note);
va_end (ap);
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap, DK_NOTE);
+ global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap,
+ diagnostics::kind::note);
va_end (ap);
}
rich_location richloc (line_table, location);
global_dc->diagnostic_n_impl (&richloc, nullptr, -1, n,
singular_gmsgid, plural_gmsgid,
- &ap, DK_NOTE);
+ &ap, diagnostics::kind::note);
va_end (ap);
}
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id,
- gmsgid, &ap, DK_WARNING);
+ gmsgid, &ap,
+ diagnostics::kind::warning);
va_end (ap);
return ret;
}
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id,
- gmsgid, &ap, DK_WARNING);
+ gmsgid, &ap,
+ diagnostics::kind::warning);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
bool ret = global_dc->diagnostic_impl (richloc, nullptr, option_id,
- gmsgid, &ap, DK_WARNING);
+ gmsgid, &ap,
+ diagnostics::kind::warning);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
bool ret = global_dc->diagnostic_impl (richloc, &metadata, option_id,
- gmsgid, &ap, DK_WARNING);
+ gmsgid, &ap,
+ diagnostics::kind::warning);
va_end (ap);
return ret;
}
va_start (ap, plural_gmsgid);
bool ret = global_dc->diagnostic_n_impl (richloc, nullptr, option_id, n,
singular_gmsgid, plural_gmsgid,
- &ap, DK_WARNING);
+ &ap, diagnostics::kind::warning);
va_end (ap);
return ret;
}
rich_location richloc (line_table, location);
bool ret = global_dc->diagnostic_n_impl (&richloc, nullptr, option_id, n,
singular_gmsgid, plural_gmsgid,
- &ap, DK_WARNING);
+ &ap, diagnostics::kind::warning);
va_end (ap);
return ret;
}
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id,
- gmsgid, &ap, DK_PEDWARN);
+ gmsgid, &ap,
+ diagnostics::kind::pedwarn);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
bool ret = global_dc->diagnostic_impl (richloc, nullptr, option_id,
- gmsgid, &ap, DK_PEDWARN);
+ gmsgid, &ap,
+ diagnostics::kind::pedwarn);
va_end (ap);
return ret;
}
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap,
- DK_PERMERROR);
+ diagnostics::kind::permerror);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
bool ret = global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap,
- DK_PERMERROR);
+ diagnostics::kind::permerror);
va_end (ap);
return ret;
}
va_start (ap, gmsgid);
rich_location richloc (line_table, location);
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id,
- gmsgid, &ap, DK_PERMERROR);
+ gmsgid, &ap,
+ diagnostics::kind::permerror);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
bool ret = global_dc->diagnostic_impl (richloc, nullptr, option_id,
- gmsgid, &ap, DK_PERMERROR);
+ gmsgid, &ap,
+ diagnostics::kind::permerror);
va_end (ap);
return ret;
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
- global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ERROR);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap,
+ diagnostics::kind::error);
va_end (ap);
}
rich_location richloc (line_table, location);
global_dc->diagnostic_n_impl (&richloc, nullptr, -1, n,
singular_gmsgid, plural_gmsgid,
- &ap, DK_ERROR);
+ &ap, diagnostics::kind::error);
va_end (ap);
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, loc);
- global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ERROR);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap,
+ diagnostics::kind::error);
va_end (ap);
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap, DK_ERROR);
+ global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap,
+ diagnostics::kind::error);
va_end (ap);
}
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
- global_dc->diagnostic_impl (richloc, &metadata, -1, gmsgid, &ap, DK_ERROR);
+ global_dc->diagnostic_impl (richloc, &metadata, -1, gmsgid, &ap,
+ diagnostics::kind::error);
va_end (ap);
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
- global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_SORRY);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap,
+ diagnostics::kind::sorry);
va_end (ap);
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, loc);
- global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_SORRY);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap,
+ diagnostics::kind::sorry);
va_end (ap);
}
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, loc);
- global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_FATAL);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap,
+ diagnostics::kind::fatal);
va_end (ap);
gcc_unreachable ();
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
- global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ICE);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap,
+ diagnostics::kind::ice);
va_end (ap);
gcc_unreachable ();
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
- global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ICE_NOBT);
+ global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap,
+ diagnostics::kind::ice_nobt);
va_end (ap);
gcc_unreachable ();
{
/* Equivalent to (seen_error () || werrorcount), but on
this context, rather than global_dc. */
- return (diagnostic_count (DK_ERROR)
- || diagnostic_count (DK_SORRY)
- || diagnostic_count (DK_WERROR));
+ return (diagnostic_count (kind::error)
+ || diagnostic_count (kind::sorry)
+ || diagnostic_count (kind::werror));
}
void
void
diagnostic_set_info_translated (diagnostic_info *diagnostic, const char *msg,
va_list *args, rich_location *richloc,
- diagnostic_t kind)
+ enum diagnostics::kind kind)
{
gcc_assert (richloc);
diagnostic->m_message.m_err_no = errno;
void
diagnostic_set_info (diagnostic_info *diagnostic, const char *gmsgid,
va_list *args, rich_location *richloc,
- diagnostic_t kind)
+ enum diagnostics::kind kind)
{
gcc_assert (richloc);
diagnostic_set_info_translated (diagnostic, _(gmsgid), args, richloc, kind);
}
+namespace diagnostics {
+
+static const char *const diagnostic_kind_text[] = {
+#define DEFINE_DIAGNOSTIC_KIND(K, T, C) (T),
+#include "diagnostics/kinds.def"
+#undef DEFINE_DIAGNOSTIC_KIND
+ "must-not-happen"
+};
+
+/* Get unlocalized string describing KIND. */
+
+const char *
+get_text_for_kind (enum kind kind)
+{
+ return diagnostic_kind_text[static_cast<int> (kind)];
+}
+
static const char *const diagnostic_kind_color[] = {
#define DEFINE_DIAGNOSTIC_KIND(K, T, C) (C),
-#include "diagnostic.def"
+#include "diagnostics/kinds.def"
#undef DEFINE_DIAGNOSTIC_KIND
nullptr
};
Result could be nullptr. */
const char *
-diagnostic_get_color_for_kind (diagnostic_t kind)
+get_color_for_kind (enum kind kind)
{
- return diagnostic_kind_color[kind];
+ return diagnostic_kind_color[static_cast<int> (kind)];
}
+} // namespace diagnostics
+
/* Given an expanded_location, convert the column (which is in 1-based bytes)
to the requested units, without converting the origin.
Return -1 if the column is invalid (<= 0). */
{
}
-static const char *const diagnostic_kind_text[] = {
-#define DEFINE_DIAGNOSTIC_KIND(K, T, C) (T),
-#include "diagnostic.def"
-#undef DEFINE_DIAGNOSTIC_KIND
- "must-not-happen"
-};
-
-/* Get unlocalized string describing KIND. */
-
-const char *
-get_diagnostic_kind_text (diagnostic_t kind)
-{
- return diagnostic_kind_text[kind];
-}
-
/* Functions at which to stop the backtrace print. It's not
particularly helpful to print the callers of these functions. */
if (!m_max_errors)
return;
- int count = (diagnostic_count (DK_ERROR)
- + diagnostic_count (DK_SORRY)
- + diagnostic_count (DK_WERROR));
+ int count = (diagnostic_count (kind::error)
+ + diagnostic_count (kind::sorry)
+ + diagnostic_count (kind::werror));
if (count >= m_max_errors)
{
is written out. This function does not always return. */
void
-diagnostics::context::action_after_output (diagnostic_t diag_kind)
+diagnostics::context::action_after_output (enum kind diag_kind)
{
switch (diag_kind)
{
- case DK_DEBUG:
- case DK_NOTE:
- case DK_ANACHRONISM:
- case DK_WARNING:
+ case kind::debug:
+ case kind::note:
+ case kind::anachronism:
+ case kind::warning:
break;
- case DK_ERROR:
- case DK_SORRY:
+ case kind::error:
+ case kind::sorry:
if (m_abort_on_error)
real_abort ();
if (m_fatal_errors)
}
break;
- case DK_ICE:
- case DK_ICE_NOBT:
+ case kind::ice:
+ case kind::ice_nobt:
{
/* Attempt to ensure that any outputs are flushed e.g. that .sarif
files are written out.
}
struct backtrace_state *state = nullptr;
- if (diag_kind == DK_ICE)
+ if (diag_kind == kind::ice)
state = backtrace_create_state (nullptr, 0, bt_err_callback, nullptr);
int count = 0;
if (state != nullptr)
exit (ICE_EXIT_CODE);
}
- case DK_FATAL:
+ case kind::fatal:
if (m_abort_on_error)
real_abort ();
fnotice (stderr, "compilation terminated.\n");
return false;
/* This tests for #pragma diagnostic changes. */
- diagnostic_t diag_class
+ enum kind diag_class
= m_option_classifier.update_effective_level_from_pragmas (diagnostic);
/* This tests if the user provided the appropriate -Werror=foo
option. */
- if (diag_class == DK_UNSPECIFIED
+ if (diag_class == kind::unspecified
&& !option_unspecified_p (diagnostic->m_option_id))
{
- const diagnostic_t new_kind
+ const enum kind new_kind
= m_option_classifier.get_current_override (diagnostic->m_option_id);
- if (new_kind != DK_ANY)
- /* DK_ANY means the diagnostic is not to be ignored, but we don't want
- to change it specifically to DK_ERROR or DK_WARNING; we want to
+ if (new_kind != kind::any)
+ /* kind::any means the diagnostic is not to be ignored, but we don't want
+ to change it specifically to kind::error or kind::warning; we want to
preserve whatever the caller has specified. */
diagnostic->m_kind = new_kind;
}
/* This allows for future extensions, like temporarily disabling
warnings for ranges of source code. */
- if (diagnostic->m_kind == DK_IGNORED)
+ if (diagnostic->m_kind == kind::ignored)
return false;
return true;
diagnostic.m_option_id = opt_id;
diagnostic.m_richloc = &richloc;
diagnostic.m_message.m_richloc = &richloc;
- diagnostic.m_kind = DK_WARNING;
+ diagnostic.m_kind = kind::warning;
return diagnostic_enabled (&diagnostic);
}
bool
diagnostics::context::
-emit_diagnostic_with_group (diagnostic_t kind,
+emit_diagnostic_with_group (enum kind kind,
rich_location &richloc,
const diagnostics::metadata *metadata,
diagnostics::option_id opt_id,
bool
diagnostics::context::
-emit_diagnostic_with_group_va (diagnostic_t kind,
+emit_diagnostic_with_group_va (enum kind kind,
rich_location &richloc,
const diagnostics::metadata *metadata,
diagnostics::option_id opt_id,
bool
diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
{
- diagnostic_t orig_diag_kind = diagnostic->m_kind;
+ enum kind orig_diag_kind = diagnostic->m_kind;
/* Every call to report_diagnostic should be within a
begin_group/end_group pair so that output formats can reliably
/* Give preference to being able to inhibit warnings, before they
get reclassified to something else. */
- bool was_warning = (diagnostic->m_kind == DK_WARNING
- || diagnostic->m_kind == DK_PEDWARN);
+ bool was_warning = (diagnostic->m_kind == kind::warning
+ || diagnostic->m_kind == kind::pedwarn);
if (was_warning && m_inhibit_warnings)
{
inhibit_notes_in_group ();
if (m_adjust_diagnostic_info)
m_adjust_diagnostic_info (this, diagnostic);
- if (diagnostic->m_kind == DK_PEDWARN)
+ if (diagnostic->m_kind == kind::pedwarn)
{
- diagnostic->m_kind = m_pedantic_errors ? DK_ERROR : DK_WARNING;
+ diagnostic->m_kind = m_pedantic_errors ? kind::error : kind::warning;
/* We do this to avoid giving the message for -pedantic-errors. */
orig_diag_kind = diagnostic->m_kind;
}
- if (diagnostic->m_kind == DK_NOTE && m_inhibit_notes_p)
+ if (diagnostic->m_kind == kind::note && m_inhibit_notes_p)
return false;
/* If the user requested that warnings be treated as errors, so be
individual warnings can be overridden back to warnings with
-Wno-error=*. */
if (m_warning_as_error_requested
- && diagnostic->m_kind == DK_WARNING)
- diagnostic->m_kind = DK_ERROR;
+ && diagnostic->m_kind == kind::warning)
+ diagnostic->m_kind = kind::error;
diagnostic->m_message.m_data = &diagnostic->m_x_data;
return false;
}
- if ((was_warning || diagnostic->m_kind == DK_WARNING)
+ if ((was_warning || diagnostic->m_kind == kind::warning)
&& ((!m_warn_system_headers
&& diagnostic->m_iinfo.m_allsyslocs)
|| m_inhibit_warnings))
inlining stack (if there is one) are in system headers. */
return false;
- if (diagnostic->m_kind == DK_NOTE && notes_inhibited_in_group ())
+ if (diagnostic->m_kind == kind::note && notes_inhibited_in_group ())
/* Bail for all the notes in the diagnostic_group that started to inhibit notes. */
return false;
- if (diagnostic->m_kind != DK_NOTE && diagnostic->m_kind != DK_ICE)
+ if (diagnostic->m_kind != kind::note && diagnostic->m_kind != kind::ice)
check_max_errors (false);
if (m_lock > 0)
/* If we're reporting an ICE in the middle of some other error,
try to flush out the previous error, then let this one
through. Don't do this more than once. */
- if ((diagnostic->m_kind == DK_ICE || diagnostic->m_kind == DK_ICE_NOBT)
+ if ((diagnostic->m_kind == kind::ice
+ || diagnostic->m_kind == kind::ice_nobt)
&& m_lock == 1)
pp_newline_and_flush (m_reference_printer);
else
m_lock++;
- if (diagnostic->m_kind == DK_ICE || diagnostic->m_kind == DK_ICE_NOBT)
+ if (diagnostic->m_kind == kind::ice || diagnostic->m_kind == kind::ice_nobt)
{
/* When not checking, ICEs are converted to fatal errors when an
error has already occurred. This is counteracted by
abort_on_error. */
if (!CHECKING_P
- && (diagnostic_count (DK_ERROR) > 0
- || diagnostic_count (DK_SORRY) > 0)
+ && (diagnostic_count (kind::error) > 0
+ || diagnostic_count (kind::sorry) > 0)
&& !m_abort_on_error)
{
expanded_location s
/* Increment the counter for the appropriate diagnostic kind, either
within this context, or within the diagnostic_buffer. */
{
- const diagnostic_t kind_for_count =
- ((diagnostic->m_kind == DK_ERROR && orig_diag_kind == DK_WARNING)
- ? DK_WERROR
+ const enum kind kind_for_count =
+ ((diagnostic->m_kind == kind::error && orig_diag_kind == kind::warning)
+ ? kind::werror
: diagnostic->m_kind);
- diagnostics::counters &counters
+ counters &cs
= (m_diagnostic_buffer
? m_diagnostic_buffer->m_diagnostic_counters
: m_diagnostic_counters);
- ++counters.m_count_for_kind[kind_for_count];
+ ++cs.m_count_for_kind[static_cast<size_t> (kind_for_count)];
}
/* Is this the initial diagnostic within the stack of groups? */
break;
}
if (m_diagnostic_buffer == nullptr
- || diagnostic->m_kind == DK_ICE
- || diagnostic->m_kind == DK_ICE_NOBT)
+ || diagnostic->m_kind == kind::ice
+ || diagnostic->m_kind == kind::ice_nobt)
action_after_output (diagnostic->m_kind);
diagnostic->m_x_data = nullptr;
const diagnostics::metadata *metadata,
diagnostics::option_id opt_id,
const char *gmsgid,
- va_list *ap, diagnostic_t kind)
+ va_list *ap, enum kind kind)
{
diagnostic_info diagnostic;
- if (kind == DK_PERMERROR)
+ if (kind == kind::permerror)
{
diagnostic_set_info (&diagnostic, gmsgid, ap, richloc,
- m_permissive ? DK_WARNING : DK_ERROR);
+ m_permissive ? kind::warning : kind::error);
diagnostic.m_option_id = (opt_id.m_idx != -1 ? opt_id : m_opt_permissive);
}
else
{
diagnostic_set_info (&diagnostic, gmsgid, ap, richloc, kind);
- if (kind == DK_WARNING || kind == DK_PEDWARN)
+ if (kind == kind::warning || kind == kind::pedwarn)
diagnostic.m_option_id = opt_id;
}
diagnostic.m_metadata = metadata;
unsigned HOST_WIDE_INT n,
const char *singular_gmsgid,
const char *plural_gmsgid,
- va_list *ap, diagnostic_t kind)
+ va_list *ap, enum kind kind)
{
diagnostic_info diagnostic;
unsigned long gtn;
const char *text = ngettext (singular_gmsgid, plural_gmsgid, gtn);
diagnostic_set_info_translated (&diagnostic, text, ap, richloc, kind);
- if (kind == DK_WARNING)
+ if (kind == kind::warning)
diagnostic.m_option_id = opt_id;
diagnostic.m_metadata = metadata;
return report_diagnostic (&diagnostic);
/* Call action_after_output to get the "please submit a bug report"
message. */
- action_after_output (DK_ICE);
+ action_after_output (kind::ice);
/* Do not use gcc_unreachable here; that goes through internal_error
and therefore would cause infinite recursion. */
if (global_dc->get_reference_printer () == nullptr)
{
/* Print the error message. */
- fnotice (stderr, diagnostic_kind_text[DK_ICE]);
+ fnotice (stderr, diagnostics::get_text_for_kind (diagnostics::kind::ice));
fnotice (stderr, "in %s, at %s:%d", function, trim_filename (file), line);
fputc ('\n', stderr);
{
fprintf (out, "%*scounts:\n", indent, "");
bool none = true;
- for (int i = 0; i < DK_LAST_DIAGNOSTIC_KIND; i++)
+ for (int i = 0; i < static_cast<int> (kind::last_diagnostic_kind); i++)
if (m_count_for_kind[i] > 0)
{
fprintf (out, "%*s%s%i\n",
indent + 2, "",
- get_diagnostic_kind_text (static_cast<diagnostic_t> (i)),
+ get_text_for_kind (static_cast<enum kind> (i)),
m_count_for_kind[i]);
none = false;
}
void
diagnostics::counters::move_to (diagnostics::counters &dest)
{
- for (int i = 0; i < DK_LAST_DIAGNOSTIC_KIND; i++)
+ for (int i = 0; i < static_cast<int> (kind::last_diagnostic_kind); i++)
dest.m_count_for_kind[i] += m_count_for_kind[i];
clear ();
}
/* The number of errors that have been issued so far. Ideally, these
would take a diagnostics::context as an argument. */
-#define errorcount global_dc->diagnostic_count (DK_ERROR)
+#define errorcount global_dc->diagnostic_count (diagnostics::kind::error)
/* Similarly, but for warnings. */
-#define warningcount global_dc->diagnostic_count (DK_WARNING)
+#define warningcount global_dc->diagnostic_count (diagnostics::kind::warning)
/* Similarly, but for warnings promoted to errors. */
-#define werrorcount global_dc->diagnostic_count (DK_WERROR)
+#define werrorcount global_dc->diagnostic_count (diagnostics::kind::werror)
/* Similarly, but for sorrys. */
-#define sorrycount global_dc->diagnostic_count (DK_SORRY)
+#define sorrycount global_dc->diagnostic_count (diagnostics::kind::sorry)
/* Returns nonzero if warnings should be emitted. */
#define diagnostic_report_warnings_p(DC, LOC) \
diagnostic_show_locus (diagnostics::context *context,
const diagnostics::source_printing_options &opts,
rich_location *richloc,
- diagnostic_t diagnostic_kind,
+ enum diagnostics::kind diagnostic_kind,
pretty_printer *pp,
diagnostics::source_effect_info *effect_info = nullptr)
{
diagnostic_show_locus_as_html (diagnostics::context *context,
const diagnostics::source_printing_options &opts,
rich_location *richloc,
- diagnostic_t diagnostic_kind,
+ enum diagnostics::kind diagnostic_kind,
xml::printer &xp,
diagnostics::source_effect_info *effect_info = nullptr,
diagnostics::html_label_writer *label_writer = nullptr)
}
/* Force diagnostics controlled by OPTIDX to be kind KIND. */
-inline diagnostic_t
+inline diagnostics::kind
diagnostic_classify_diagnostic (diagnostics::context *context,
diagnostics::option_id opt_id,
- diagnostic_t kind,
+ enum diagnostics::kind kind,
location_t where)
{
return context->classify_diagnostic (opt_id, kind, where);
#ifdef ATTRIBUTE_GCC_DIAG
extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
- rich_location *, diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0);
+ rich_location *, enum diagnostics::kind) ATTRIBUTE_GCC_DIAG(2,0);
extern void diagnostic_set_info_translated (diagnostic_info *, const char *,
va_list *, rich_location *,
- diagnostic_t)
+ enum diagnostics::kind)
ATTRIBUTE_GCC_DIAG(2,0);
#endif
expanded_location);
void default_text_finalizer (diagnostics::text_sink &,
const diagnostic_info *,
- diagnostic_t);
+ enum diagnostics::kind);
} // namespace diagnostics
void diagnostic_set_caret_max_width (diagnostics::context *context, int value);
> abs (s1.column - s2.column)));
}
-extern const char *diagnostic_get_color_for_kind (diagnostic_t kind);
-
/* Pure text formatting support functions. */
extern char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1;
extern char *get_cwe_url (int cwe);
-extern const char *get_diagnostic_kind_text (diagnostic_t kind);
-
namespace diagnostics {
const char *maybe_line_and_column (int line, int col);
context::flush_diagnostic_buffer (buffer &buffer_)
{
bool had_errors
- = (buffer_.m_diagnostic_counters.m_count_for_kind[DK_ERROR] > 0
- || buffer_.m_diagnostic_counters.m_count_for_kind[DK_WERROR] > 0);
+ = (buffer_.diagnostic_count (kind::error) > 0
+ || buffer_.diagnostic_count (kind::werror) > 0);
if (buffer_.m_per_sink_buffers)
for (auto per_sink_buffer_ : *buffer_.m_per_sink_buffers)
per_sink_buffer_->flush ();
buffer_.m_diagnostic_counters.move_to (m_diagnostic_counters);
- action_after_output (had_errors ? DK_ERROR : DK_WARNING);
+ action_after_output (had_errors ? kind::error : kind::warning);
check_max_errors (true);
}
void dump (FILE *out, int indent) const;
void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
- int diagnostic_count (diagnostic_t kind) const
+ int diagnostic_count (enum kind kind) const
{
return m_diagnostic_counters.get_count (kind);
}
typedef void (*text_finalizer_fn) (text_sink &,
const diagnostic_info *,
- diagnostic_t);
+ enum kind);
/* Abstract base class for the diagnostic subsystem to make queries
about command-line options. */
May return NULL if no name is to be printed.
May be passed 0 as well as the index of a particular option. */
virtual char *make_option_name (option_id opt_id,
- diagnostic_t orig_diag_kind,
- diagnostic_t diag_kind) const = 0;
+ enum kind orig_diag_kind,
+ enum kind diag_kind) const = 0;
/* Return malloced memory for a URL describing the option that controls
a diagnostic.
void
print (pretty_printer &pp,
const rich_location &richloc,
- diagnostic_t diagnostic_kind,
+ enum kind diagnostic_kind,
source_effect_info *effect_info) const;
void
print_as_html (xml::printer &xp,
const rich_location &richloc,
- diagnostic_t diagnostic_kind,
+ enum kind diagnostic_kind,
source_effect_info *effect_info,
html_label_writer *label_writer) const;
void dump (FILE *out, int indent) const;
void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
- int get_count (diagnostic_t kind) const { return m_count_for_kind[kind]; }
+ int get_count (enum kind kind) const
+ {
+ return m_count_for_kind[static_cast<size_t> (kind)];
+ }
void move_to (counters &dest);
void clear ();
- int m_count_for_kind[DK_LAST_DIAGNOSTIC_KIND];
+ int m_count_for_kind[static_cast<size_t> (kind::last_diagnostic_kind)];
};
/* This class encapsulates the state of the diagnostics subsystem
return m_option_classifier.option_unspecified_p (opt_id);
}
- bool emit_diagnostic_with_group (diagnostic_t kind,
+ bool emit_diagnostic_with_group (enum kind kind,
rich_location &richloc,
const metadata *metadata,
option_id opt_id,
const char *gmsgid, ...)
ATTRIBUTE_GCC_DIAG(6,7);
- bool emit_diagnostic_with_group_va (diagnostic_t kind,
+ bool emit_diagnostic_with_group_va (enum kind kind,
rich_location &richloc,
const metadata *metadata,
option_id opt_id,
void
report_global_digraph (const digraphs::lazy_digraph &);
- diagnostic_t
+ enum kind
classify_diagnostic (option_id opt_id,
- diagnostic_t new_kind,
+ enum kind new_kind,
location_t where)
{
return m_option_classifier.classify_diagnostic (this,
void maybe_show_locus (const rich_location &richloc,
const source_printing_options &opts,
- diagnostic_t diagnostic_kind,
+ enum kind diagnostic_kind,
pretty_printer &pp,
source_effect_info *effect_info);
void maybe_show_locus_as_html (const rich_location &richloc,
const source_printing_options &opts,
- diagnostic_t diagnostic_kind,
+ enum kind diagnostic_kind,
xml::printer &xp,
source_effect_info *effect_info,
html_label_writer *label_writer);
text_art::theme *get_diagram_theme () const { return m_diagrams.m_theme; }
- int &diagnostic_count (diagnostic_t kind)
+ int &diagnostic_count (enum kind kind)
{
- return m_diagnostic_counters.m_count_for_kind[kind];
+ return m_diagnostic_counters.m_count_for_kind[static_cast<size_t> (kind)];
}
- int diagnostic_count (diagnostic_t kind) const
+ int diagnostic_count (enum kind kind) const
{
return m_diagnostic_counters.get_count (kind);
}
}
inline char *make_option_name (option_id opt_id,
- diagnostic_t orig_diag_kind,
- diagnostic_t diag_kind) const
+ enum kind orig_diag_kind,
+ enum kind diag_kind) const
{
if (!m_option_mgr)
return nullptr;
bool diagnostic_impl (rich_location *, const metadata *,
option_id, const char *,
- va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
+ va_list *, enum kind) ATTRIBUTE_GCC_DIAG(5,0);
bool diagnostic_n_impl (rich_location *, const metadata *,
option_id, unsigned HOST_WIDE_INT,
const char *, const char *, va_list *,
- diagnostic_t) ATTRIBUTE_GCC_DIAG(7,0);
+ enum kind) ATTRIBUTE_GCC_DIAG(7,0);
int get_diagnostic_nesting_level () const
{
bool supports_fnotice_on_stderr_p () const;
- /* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */
+ /* Raise SIGABRT on any diagnostic of severity kind::error or higher. */
void
set_abort_on_error (bool val)
{
void get_any_inlining_info (diagnostic_info *diagnostic);
void check_max_errors (bool flush);
- void action_after_output (diagnostic_t diag_kind);
+ void action_after_output (enum kind diag_kind);
/* Data members.
Ideally, all of these would be private. */
/* A diagnostic is described by the MESSAGE to send, the FILE and LINE of
its context and its KIND (ice, error, warning, note, ...) See complete
- list in diagnostic.def. */
+ list in diagnostics/kinds.def. */
struct diagnostic_info
{
/* Auxiliary data for client. */
void *m_x_data;
/* The kind of diagnostic it is about. */
- diagnostic_t m_kind;
+ kind m_kind;
/* Which OPT_* directly controls this diagnostic. */
option_id m_option_id;
set_main_input_filename (const char *name);
void on_report_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind,
+ enum kind orig_diag_kind,
html_sink_buffer *buffer);
void emit_diagram (const diagram &d);
void emit_global_graph (const digraphs::lazy_digraph &);
std::unique_ptr<xml::element>
make_element_for_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind,
+ enum kind orig_diag_kind,
bool alert);
std::unique_ptr<xml::element>
void
html_builder::on_report_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind,
+ enum kind orig_diag_kind,
html_sink_buffer *buffer)
{
- if (diagnostic.m_kind == DK_ICE || diagnostic.m_kind == DK_ICE_NOBT)
+ if (diagnostic.m_kind == kind::ice || diagnostic.m_kind == kind::ice_nobt)
{
/* Print a header for the remaining output to stderr, and
return, attempting to print the usual ICE messages to
/* See https://pf3.patternfly.org/v3/pattern-library/widgets/#alerts */
static const char *
-get_pf_class_for_alert_div (diagnostic_t diag_kind)
+get_pf_class_for_alert_div (enum kind diag_kind)
{
switch (diag_kind)
{
- case DK_DEBUG:
- case DK_NOTE:
+ case kind::debug:
+ case kind::note:
return "alert alert-info";
- case DK_ANACHRONISM:
- case DK_WARNING:
+ case kind::anachronism:
+ case kind::warning:
return "alert alert-warning";
- case DK_ERROR:
- case DK_SORRY:
- case DK_ICE:
- case DK_ICE_NOBT:
- case DK_FATAL:
+ case kind::error:
+ case kind::sorry:
+ case kind::ice:
+ case kind::ice_nobt:
+ case kind::fatal:
return "alert alert-danger";
default:
}
static const char *
-get_pf_class_for_alert_icon (diagnostic_t diag_kind)
+get_pf_class_for_alert_icon (enum kind diag_kind)
{
switch (diag_kind)
{
- case DK_DEBUG:
- case DK_NOTE:
+ case kind::debug:
+ case kind::note:
return "pficon pficon-info";
- case DK_ANACHRONISM:
- case DK_WARNING:
+ case kind::anachronism:
+ case kind::warning:
return "pficon pficon-warning-triangle-o";
- case DK_ERROR:
- case DK_SORRY:
- case DK_ICE:
- case DK_ICE_NOBT:
- case DK_FATAL:
+ case kind::error:
+ case kind::sorry:
+ case kind::ice:
+ case kind::ice_nobt:
+ case kind::fatal:
return "pficon pficon-error-circle-o";
default:
std::unique_ptr<xml::element>
html_builder::make_element_for_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind,
+ enum kind orig_diag_kind,
bool alert)
{
const int diag_idx = m_next_diag_id++;
if (show_severity)
{
xp.push_tag ("strong");
- xp.add_text (_(get_diagnostic_kind_text (diagnostic.m_kind)));
+ xp.add_text (_(get_text_for_kind (diagnostic.m_kind)));
xp.pop_tag ("strong");
xp.add_text (" ");
}
}
void
on_report_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind) final override
+ enum kind orig_diag_kind) final override
{
m_builder.on_report_diagnostic (diagnostic, orig_diag_kind, m_buffer);
}
{
rich_location richloc (line_maps, UNKNOWN_LOCATION);
dc.emit_diagnostic_with_group
- (DK_ERROR, richloc, nullptr, 0,
+ (kind::error, richloc, nullptr, 0,
"unable to determine filename for HTML output");
return output_file ();
}
{
rich_location richloc (line_maps, UNKNOWN_LOCATION);
dc.emit_diagnostic_with_group
- (DK_ERROR, richloc, nullptr, 0,
+ (kind::error, richloc, nullptr, 0,
"unable to open %qs for HTML output: %m",
filename.get ());
return output_file ();
test_html_context dc;
rich_location richloc (line_table, UNKNOWN_LOCATION);
- dc.report (DK_ERROR, richloc, nullptr, 0, "this is a test: %qs", "foo");
+ dc.report (kind::error, richloc, nullptr, 0, "this is a test: %qs", "foo");
const xml::document &doc = dc.get_document ();
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-/* DK_UNSPECIFIED must be first so it has a value of zero. We never
+/* kind::unspecified must be first so it has a value of zero. We never
assign this kind to an actual diagnostic, we only use this in
variables that can hold a kind, to mean they have yet to have a
kind specified. I.e. they're uninitialized. Within the diagnostic
machinery, this kind also means "don't change the existing kind",
meaning "no change is specified". */
-DEFINE_DIAGNOSTIC_KIND (DK_UNSPECIFIED, "", NULL)
+DEFINE_DIAGNOSTIC_KIND (unspecified, "", NULL)
-/* If a diagnostic is set to DK_IGNORED, it won't get reported at all.
+/* If a diagnostic is set to kind::ignored, it won't get reported at all.
This is used by the diagnostic machinery when it wants to disable a
diagnostic without disabling the option which causes it. */
-DEFINE_DIAGNOSTIC_KIND (DK_IGNORED, "", NULL)
+DEFINE_DIAGNOSTIC_KIND (ignored, "", NULL)
/* The remainder are real diagnostic types. */
-DEFINE_DIAGNOSTIC_KIND (DK_FATAL, "fatal error: ", "error")
-DEFINE_DIAGNOSTIC_KIND (DK_ICE, "internal compiler error: ", "error")
-DEFINE_DIAGNOSTIC_KIND (DK_ERROR, "error: ", "error")
-DEFINE_DIAGNOSTIC_KIND (DK_SORRY, "sorry, unimplemented: ", "error")
-DEFINE_DIAGNOSTIC_KIND (DK_WARNING, "warning: ", "warning")
-DEFINE_DIAGNOSTIC_KIND (DK_ANACHRONISM, "anachronism: ", "warning")
-DEFINE_DIAGNOSTIC_KIND (DK_NOTE, "note: ", "note")
-DEFINE_DIAGNOSTIC_KIND (DK_DEBUG, "debug: ", "note")
+DEFINE_DIAGNOSTIC_KIND (fatal, "fatal error: ", "error")
+DEFINE_DIAGNOSTIC_KIND (ice, "internal compiler error: ", "error")
+DEFINE_DIAGNOSTIC_KIND (error, "error: ", "error")
+DEFINE_DIAGNOSTIC_KIND (sorry, "sorry, unimplemented: ", "error")
+DEFINE_DIAGNOSTIC_KIND (warning, "warning: ", "warning")
+DEFINE_DIAGNOSTIC_KIND (anachronism, "anachronism: ", "warning")
+DEFINE_DIAGNOSTIC_KIND (note, "note: ", "note")
+DEFINE_DIAGNOSTIC_KIND (debug, "debug: ", "note")
/* For use when using the diagnostic_show_locus machinery to show
a range of events within a path. */
-DEFINE_DIAGNOSTIC_KIND (DK_DIAGNOSTIC_PATH, "path: ", "path")
+DEFINE_DIAGNOSTIC_KIND (path, "path: ", "path")
-/* These two would be re-classified as DK_WARNING or DK_ERROR, so the
+/* These two would be re-classified as kind::warning or kind::error, so the
prefix does not matter. */
-DEFINE_DIAGNOSTIC_KIND (DK_PEDWARN, "pedwarn: ", NULL)
-DEFINE_DIAGNOSTIC_KIND (DK_PERMERROR, "permerror: ", NULL)
-/* This one is just for counting DK_WARNING promoted to DK_ERROR
+DEFINE_DIAGNOSTIC_KIND (pedwarn, "pedwarn: ", NULL)
+DEFINE_DIAGNOSTIC_KIND (permerror, "permerror: ", NULL)
+/* This one is just for counting kind::warning promoted to kind::error
due to -Werror and -Werror=warning. */
-DEFINE_DIAGNOSTIC_KIND (DK_WERROR, "error: ", NULL)
-/* This is like DK_ICE, but backtrace is not printed. Used in the driver
+DEFINE_DIAGNOSTIC_KIND (werror, "error: ", NULL)
+/* This is like kind::ICE, but backtrace is not printed. Used in the driver
when reporting fatal signal in the compiler. */
-DEFINE_DIAGNOSTIC_KIND (DK_ICE_NOBT, "internal compiler error: ", "error")
+DEFINE_DIAGNOSTIC_KIND (ice_nobt, "internal compiler error: ", "error")
--- /dev/null
+/* An enum used to discriminate severities of diagnostics.
+ Copyright (C) 1998-2025 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_DIAGNOSTICS_KINDS_H
+#define GCC_DIAGNOSTICS_KINDS_H
+
+namespace diagnostics {
+
+/* Constants used to discriminate diagnostics. */
+enum class kind
+{
+#define DEFINE_DIAGNOSTIC_KIND(K, msgid, C) K,
+#include "diagnostics/kinds.def"
+#undef DEFINE_DIAGNOSTIC_KIND
+ last_diagnostic_kind,
+ /* This is used for tagging pragma pops in the diagnostic
+ classification history chain. */
+ pop,
+ /* This is used internally to note that a diagnostic is enabled
+ without mandating any specific type. */
+ any
+};
+
+extern const char *get_text_for_kind (enum diagnostics::kind);
+extern const char *get_color_for_kind (enum diagnostics::kind);
+
+} // namespace diagnostics
+
+#endif /* ! GCC_DIAGNOSTICS_KINDS_H */
return 0;
}
char *make_option_name (diagnostics::option_id,
- diagnostic_t,
- diagnostic_t) const final override
+ enum kind,
+ enum kind) const final override
{
return nullptr;
}
diagnostics::option_id opt_id (42); // has to be non-zero
bool emitted
- = dc.emit_diagnostic_with_group (DK_WARNING, rich_loc, nullptr,
+ = dc.emit_diagnostic_with_group (kind::warning, rich_loc, nullptr,
opt_id,
"this warning should be skipped");
ASSERT_FALSE (emitted);
ASSERT_FALSE (rich_loc.m_path.generated_p ());
bool emitted
- = dc.emit_diagnostic_with_group (DK_ERROR, rich_loc, nullptr, 0,
+ = dc.emit_diagnostic_with_group (kind::error, rich_loc, nullptr, 0,
"this is a test");
ASSERT_TRUE (emitted);
ASSERT_TRUE (rich_loc.m_path.generated_p ());
option_classifier::init (int n_opts)
{
m_n_opts = n_opts;
- m_classify_diagnostic = XNEWVEC (diagnostic_t, n_opts);
+ m_classify_diagnostic = XNEWVEC (enum kind, n_opts);
for (int i = 0; i < n_opts; i++)
- m_classify_diagnostic[i] = DK_UNSPECIFIED;
+ m_classify_diagnostic[i] = kind::unspecified;
m_push_list = vNULL;
m_classification_history = vNULL;
}
else
jump_to = 0;
- classification_change_t v = { where, jump_to, DK_POP };
+ classification_change_t v = { where, jump_to, kind::pop };
m_classification_history.safe_push (v);
}
/* Interface to specify diagnostic kind overrides. Returns the
- previous setting, or DK_UNSPECIFIED if the parameters are out of
+ previous setting, or kind::unspecified if the parameters are out of
range. If OPTION_ID is zero, the new setting is for all the
diagnostics. */
-diagnostic_t
+enum kind
option_classifier::classify_diagnostic (const context *dc,
option_id opt_id,
- diagnostic_t new_kind,
+ enum kind new_kind,
location_t where)
{
- diagnostic_t old_kind;
+ enum kind old_kind;
if (opt_id.m_idx < 0
|| opt_id.m_idx >= m_n_opts
- || new_kind >= DK_LAST_DIAGNOSTIC_KIND)
- return DK_UNSPECIFIED;
+ || new_kind >= kind::last_diagnostic_kind)
+ return kind::unspecified;
old_kind = m_classify_diagnostic[opt_id.m_idx];
{
unsigned i;
- /* Record the command-line status, so we can reset it back on DK_POP. */
- if (old_kind == DK_UNSPECIFIED)
+ /* Record the command-line status, so we can reset it back on kind::pop. */
+ if (old_kind == kind::unspecified)
{
old_kind = (!dc->option_enabled_p (opt_id)
- ? DK_IGNORED : DK_ANY);
+ ? kind::ignored : kind::any);
m_classify_diagnostic[opt_id.m_idx] = old_kind;
}
#pragma GCC diagnostic
directives recorded within this object.
- Return the new kind of DIAGNOSTIC if it was updated, or DK_UNSPECIFIED
+ Return the new kind of DIAGNOSTIC if it was updated, or kind::unspecified
otherwise. */
-diagnostic_t
+enum kind
option_classifier::
update_effective_level_from_pragmas (diagnostic_info *diagnostic) const
{
if (m_classification_history.is_empty ())
- return DK_UNSPECIFIED;
+ return kind::unspecified;
/* Iterate over the locations, checking the diagnostic disposition
for the diagnostic at each. If it's explicitly set as opposed
if (!linemap_location_before_p (line_table, pragloc, loc))
continue;
- if (p->kind == (int) DK_POP)
+ if (p->kind == kind::pop)
{
/* Move on to the next region. */
i = p->option;
/* The option 0 is for all the diagnostics. */
if (opt_id == 0 || opt_id == diagnostic->m_option_id)
{
- diagnostic_t kind = p->kind;
- if (kind != DK_UNSPECIFIED)
+ enum kind kind = p->kind;
+ if (kind != kind::unspecified)
diagnostic->m_kind = kind;
return kind;
}
}
}
- return DK_UNSPECIFIED;
+ return kind::unspecified;
}
} // namespace diagnostics
bool option_unspecified_p (option_id opt_id) const
{
- return get_current_override (opt_id) == DK_UNSPECIFIED;
+ return get_current_override (opt_id) == kind::unspecified;
}
- diagnostic_t get_current_override (option_id opt_id) const
+ enum kind get_current_override (option_id opt_id) const
{
gcc_assert (opt_id.m_idx < m_n_opts);
return m_classify_diagnostic[opt_id.m_idx];
}
- diagnostic_t
+ enum kind
classify_diagnostic (const context *context,
option_id opt_id,
- diagnostic_t new_kind,
+ enum kind new_kind,
location_t where);
- diagnostic_t
+ enum kind
update_effective_level_from_pragmas (diagnostic_info *diagnostic) const;
int pch_save (FILE *);
{
location_t location;
- /* For DK_POP, this is the index of the corresponding push (as stored
+ /* For kind::pop, this is the index of the corresponding push (as stored
in m_push_list).
Otherwise, this is an option index. */
int option;
- diagnostic_t kind;
+ enum kind kind;
};
int m_n_opts;
/* For each option index that can be passed to warning() et al
(OPT_* from options.h when using this code with the core GCC
options), this array may contain a new kind that the diagnostic
- should be changed to before reporting, or DK_UNSPECIFIED to leave
- it as the reported kind, or DK_IGNORED to not report it at
+ should be changed to before reporting, or kind::unspecified to leave
+ it as the reported kind, or kind::ignored to not report it at
all. */
- diagnostic_t *m_classify_diagnostic;
+ enum kind *m_classify_diagnostic;
/* History of all changes to the classifications above. This list
is stored in location-order, so we can search it, either
{
m_dc.begin_group ();
rich_location richloc (m_control_location_mgr, m_loc);
- m_dc.diagnostic_impl (&richloc, nullptr, -1, gmsgid, ap, DK_ERROR);
+ m_dc.diagnostic_impl (&richloc, nullptr, -1, gmsgid, ap, kind::error);
m_dc.end_group ();
}
/* Call diagnostic_show_locus to show the events using labels. */
diagnostic_show_locus (&dc, text_output.get_source_printing_options (),
- &m_richloc, DK_DIAGNOSTIC_PATH, &pp,
+ &m_richloc, diagnostics::kind::path, &pp,
effect_info);
/* If we have a macro expansion, show the expansion to the user. */
/* Call diagnostic_show_locus_as_html to show the source,
showing events using labels. */
diagnostic_show_locus_as_html (&dc, dc.m_source_printing,
- &m_richloc, DK_DIAGNOSTIC_PATH, xp,
+ &m_richloc, diagnostics::kind::path, xp,
effect_info, event_label_writer);
// TODO: show macro expansions
void
on_nested_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind,
+ enum kind orig_diag_kind,
sarif_builder &builder);
void on_diagram (const diagram &d,
sarif_builder &builder);
set_main_input_filename (const char *name);
void on_report_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind,
+ enum kind orig_diag_kind,
sarif_sink_buffer *buffer);
void emit_diagram (const diagram &d);
void end_group ();
std::unique_ptr<sarif_result>
make_result_object (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind,
+ enum kind orig_diag_kind,
unsigned idx_within_parent);
void
add_any_include_chain (sarif_location_manager &loc_mgr,
make_tool_component_reference_object_for_cwe () const;
std::unique_ptr<sarif_reporting_descriptor>
make_reporting_descriptor_object_for_warning (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind,
+ enum kind orig_diag_kind,
const char *option_text);
std::unique_ptr<sarif_reporting_descriptor>
make_reporting_descriptor_object_for_cwe_id (int cwe_id) const;
void
sarif_result::on_nested_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t /*orig_diag_kind*/,
+ enum kind /*orig_diag_kind*/,
sarif_builder &builder)
{
/* We don't yet generate meaningful logical locations for notes;
void
sarif_builder::on_report_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind,
+ enum kind orig_diag_kind,
sarif_sink_buffer *buffer)
{
pp_output_formatted_text (m_printer, m_context.get_urlifier ());
- if (diagnostic.m_kind == DK_ICE || diagnostic.m_kind == DK_ICE_NOBT)
+ if (diagnostic.m_kind == kind::ice || diagnostic.m_kind == kind::ice_nobt)
{
std::unique_ptr<json::object> stack = make_stack_from_backtrace ();
m_invocation_obj->add_notification_for_ice (diagnostic, *this,
Return nullptr if there isn't one. */
static const char *
-maybe_get_sarif_level (diagnostic_t diag_kind)
+maybe_get_sarif_level (enum kind diag_kind)
{
switch (diag_kind)
{
- case DK_WARNING:
+ case kind::warning:
return "warning";
- case DK_ERROR:
+ case kind::error:
return "error";
- case DK_NOTE:
- case DK_ANACHRONISM:
+ case kind::note:
+ case kind::anachronism:
return "note";
default:
return nullptr;
have anything better to use. */
static char *
-make_rule_id_for_diagnostic_kind (diagnostic_t diag_kind)
+make_rule_id_for_diagnostic_kind (enum kind diag_kind)
{
/* Lose the trailing ": ". */
- const char *kind_text = get_diagnostic_kind_text (diag_kind);
+ const char *kind_text = get_text_for_kind (diag_kind);
size_t len = strlen (kind_text);
gcc_assert (len > 2);
gcc_assert (kind_text[len - 2] == ':');
std::unique_ptr<sarif_result>
sarif_builder::make_result_object (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind,
+ enum kind orig_diag_kind,
unsigned idx_within_parent)
{
auto result_obj = std::make_unique<sarif_result> (idx_within_parent);
std::unique_ptr<sarif_reporting_descriptor>
sarif_builder::
make_reporting_descriptor_object_for_warning (const diagnostic_info &diagnostic,
- diagnostic_t /*orig_diag_kind*/,
+ enum kind /*orig_diag_kind*/,
const char *option_text)
{
auto reporting_desc = std::make_unique<sarif_reporting_descriptor> ();
dc.set_escape_format (m_escape_format);
text_sink text_output (dc);
source_policy.print (*text_output.get_printer (),
- my_rich_loc, DK_ERROR, nullptr);
+ my_rich_loc, kind::error, nullptr);
const char *buf = pp_formatted_text (text_output.get_printer ());
std::unique_ptr<sarif_multiformat_message_string> result
}
void
on_report_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind) final override
+ enum kind orig_diag_kind) final override
{
m_builder.on_report_diagnostic (diagnostic, orig_diag_kind, m_buffer);
}
{
rich_location richloc (line_maps, UNKNOWN_LOCATION);
dc.emit_diagnostic_with_group
- (DK_ERROR, richloc, nullptr, 0,
+ (kind::error, richloc, nullptr, 0,
"unable to determine filename for SARIF output");
return output_file ();
}
{
rich_location richloc (line_maps, UNKNOWN_LOCATION);
dc.emit_diagnostic_with_group
- (DK_ERROR, richloc, nullptr, 0,
+ (kind::error, richloc, nullptr, 0,
"unable to open %qs for diagnostic output: %m",
filename.get ());
return output_file ();
test_sarif_diagnostic_context dc ("MAIN_INPUT_FILENAME", sarif_gen_opts);
rich_location richloc (line_table, UNKNOWN_LOCATION);
- dc.report (DK_ERROR, richloc, nullptr, 0, "this is a test: %i", 42);
+ dc.report (kind::error, richloc, nullptr, 0, "this is a test: %i", 42);
auto log_ptr = dc.flush_to_object ();
linemap_position_for_column (line_table, 8));
rich_location richloc (line_table, typo_loc);
- dc.report (DK_ERROR, richloc, nullptr, 0,
+ dc.report (kind::error, richloc, nullptr, 0,
"did you misspell %qs again?",
"unsigned");
{
test_sarif_diagnostic_context dc ("test.c", sarif_gen_opts);
rich_location richloc (line_table, UNKNOWN_LOCATION);
- dc.report (DK_ERROR, richloc, nullptr, 0,
+ dc.report (kind::error, richloc, nullptr, 0,
"before %{text%} after",
"http://example.com");
std::unique_ptr<sarif_log> log = dc.flush_to_object ();
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wformat-diag"
#endif
- dc.report (DK_ERROR, richloc, nullptr, 0,
+ dc.report (kind::error, richloc, nullptr, 0,
"Prohibited term used in %{para[0]\\spans[2]%}.",
"1");
#if __GNUC__ >= 10
test_sarif_diagnostic_context dc ("test.c", sarif_gen_opts);
dc.push_owned_urlifier (std::make_unique<test_urlifier> ());
rich_location richloc (line_table, UNKNOWN_LOCATION);
- dc.report (DK_ERROR, richloc, nullptr, 0,
+ dc.report (kind::error, richloc, nullptr, 0,
"foo %<-foption%> %<unrecognized%> bar");
std::unique_ptr<sarif_log> log = dc.flush_to_object ();
{
test_sarif_diagnostic_context dc ("test.c", sarif_gen_opts);
rich_location richloc (line_table, UNKNOWN_LOCATION);
- dc.report (DK_ERROR, richloc, nullptr, 0,
+ dc.report (kind::error, richloc, nullptr, 0,
"open brace: %qs close brace: %qs",
"{", "}");
std::unique_ptr<sarif_log> log = dc.flush_to_object ();
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
- ASSERT_EQ (dc.diagnostic_count (DK_ERROR), 0);
- ASSERT_EQ (buf_a.diagnostic_count (DK_ERROR), 0);
- ASSERT_EQ (buf_b.diagnostic_count (DK_ERROR), 0);
+ ASSERT_EQ (dc.diagnostic_count (kind::error), 0);
+ ASSERT_EQ (buf_a.diagnostic_count (kind::error), 0);
+ ASSERT_EQ (buf_b.diagnostic_count (kind::error), 0);
ASSERT_EQ (dc.num_results (), 0);
ASSERT_TRUE (buf_a.empty_p ());
ASSERT_TRUE (buf_b.empty_p ());
/* Unbuffered diagnostic. */
{
- dc.report (DK_ERROR, rich_loc, nullptr, 0,
+ dc.report (kind::error, rich_loc, nullptr, 0,
"message 1");
- ASSERT_EQ (dc.diagnostic_count (DK_ERROR), 1);
- ASSERT_EQ (buf_a.diagnostic_count (DK_ERROR), 0);
- ASSERT_EQ (buf_b.diagnostic_count (DK_ERROR), 0);
+ ASSERT_EQ (dc.diagnostic_count (kind::error), 1);
+ ASSERT_EQ (buf_a.diagnostic_count (kind::error), 0);
+ ASSERT_EQ (buf_b.diagnostic_count (kind::error), 0);
ASSERT_EQ (dc.num_results (), 1);
sarif_result &result_obj = dc.get_result (0);
auto message_obj = get_message_from_result (result_obj);
/* Buffer diagnostic into buffer A. */
{
dc.set_diagnostic_buffer (&buf_a);
- dc.report (DK_ERROR, rich_loc, nullptr, 0,
+ dc.report (kind::error, rich_loc, nullptr, 0,
"message in buffer a");
- ASSERT_EQ (dc.diagnostic_count (DK_ERROR), 1);
- ASSERT_EQ (buf_a.diagnostic_count (DK_ERROR), 1);
- ASSERT_EQ (buf_b.diagnostic_count (DK_ERROR), 0);
+ ASSERT_EQ (dc.diagnostic_count (kind::error), 1);
+ ASSERT_EQ (buf_a.diagnostic_count (kind::error), 1);
+ ASSERT_EQ (buf_b.diagnostic_count (kind::error), 0);
ASSERT_EQ (dc.num_results (), 1);
ASSERT_FALSE (buf_a.empty_p ());
ASSERT_TRUE (buf_b.empty_p ());
/* Buffer diagnostic into buffer B. */
{
dc.set_diagnostic_buffer (&buf_b);
- dc.report (DK_ERROR, rich_loc, nullptr, 0,
+ dc.report (kind::error, rich_loc, nullptr, 0,
"message in buffer b");
- ASSERT_EQ (dc.diagnostic_count (DK_ERROR), 1);
- ASSERT_EQ (buf_a.diagnostic_count (DK_ERROR), 1);
- ASSERT_EQ (buf_b.diagnostic_count (DK_ERROR), 1);
+ ASSERT_EQ (dc.diagnostic_count (kind::error), 1);
+ ASSERT_EQ (buf_a.diagnostic_count (kind::error), 1);
+ ASSERT_EQ (buf_b.diagnostic_count (kind::error), 1);
ASSERT_EQ (dc.num_results (), 1);
ASSERT_FALSE (buf_a.empty_p ());
ASSERT_FALSE (buf_b.empty_p ());
/* Flush buffer B to dc. */
{
dc.flush_diagnostic_buffer (buf_b);
- ASSERT_EQ (dc.diagnostic_count (DK_ERROR), 2);
- ASSERT_EQ (buf_a.diagnostic_count (DK_ERROR), 1);
- ASSERT_EQ (buf_b.diagnostic_count (DK_ERROR), 0);
+ ASSERT_EQ (dc.diagnostic_count (kind::error), 2);
+ ASSERT_EQ (buf_a.diagnostic_count (kind::error), 1);
+ ASSERT_EQ (buf_b.diagnostic_count (kind::error), 0);
ASSERT_EQ (dc.num_results (), 2);
sarif_result &result_1_obj = dc.get_result (1);
auto message_1_obj = get_message_from_result (result_1_obj);
/* Clear buffer A. */
{
dc.clear_diagnostic_buffer (buf_a);
- ASSERT_EQ (dc.diagnostic_count (DK_ERROR), 2);
- ASSERT_EQ (buf_a.diagnostic_count (DK_ERROR), 0);
- ASSERT_EQ (buf_b.diagnostic_count (DK_ERROR), 0);
+ ASSERT_EQ (dc.diagnostic_count (kind::error), 2);
+ ASSERT_EQ (buf_a.diagnostic_count (kind::error), 0);
+ ASSERT_EQ (buf_b.diagnostic_count (kind::error), 0);
ASSERT_EQ (dc.num_results (), 2);
ASSERT_TRUE (buf_a.empty_p ());
ASSERT_TRUE (buf_b.empty_p ());
}
bool
-test_context::report (diagnostic_t kind,
+test_context::report (enum kind kind,
rich_location &richloc,
const metadata *metadata_,
option_id opt_id,
pretty_printer *pp = get_reference_printer ();
gcc_assert (pp);
source_print_policy source_policy (*this);
- source_policy.print (*pp, richloc, DK_ERROR, nullptr);
+ source_policy.print (*pp, richloc, kind::error, nullptr);
return pp_formatted_text (pp);
}
should only be called on a context that uses a non-standard formatter
that e.g. gathers the results in memory, rather than emits to stderr. */
bool
- report (diagnostic_t kind,
+ report (enum kind kind,
rich_location &richloc,
const metadata *,
option_id opt_id,
/* Vfunc with responsibility for phase 3 of formatting the message
and "printing" the result. */
virtual void on_report_diagnostic (const diagnostic_info &,
- diagnostic_t orig_diag_kind) = 0;
+ enum kind orig_diag_kind) = 0;
virtual void on_report_verbatim (text_info &);
public:
colorizer (pretty_printer &pp,
const rich_location &richloc,
- diagnostic_t diagnostic_kind);
+ enum diagnostics::kind diagnostic_kind);
~colorizer ();
void set_range (int range_idx)
two colors for the secondary locations.
But if we're printing a run of events in a diagnostic path, that
makes no sense, so print all of them with the same colorization. */
- if (m_diagnostic_kind == DK_DIAGNOSTIC_PATH)
+ if (m_diagnostic_kind == diagnostics::kind::path)
set_state (0);
else
set_state (range_idx);
pretty_printer &m_pp;
const rich_location &m_richloc;
- diagnostic_t m_diagnostic_kind;
+ enum diagnostics::kind m_diagnostic_kind;
int m_current_state;
const char *m_range1;
const char *m_range2;
colorizer::colorizer (pretty_printer &pp,
const rich_location &richloc,
- diagnostic_t diagnostic_kind) :
+ enum diagnostics::kind diagnostic_kind) :
m_pp (pp),
m_richloc (richloc),
m_diagnostic_kind (diagnostic_kind),
pp_string
(&m_pp,
colorize_start (pp_show_color (&m_pp),
- diagnostic_get_color_for_kind (m_diagnostic_kind)));
+ get_color_for_kind (m_diagnostic_kind)));
break;
case 1:
void
context::maybe_show_locus (const rich_location &richloc,
const source_printing_options &opts,
- diagnostic_t diagnostic_kind,
+ enum kind diagnostic_kind,
pretty_printer &pp,
source_effect_info *effects)
{
void
context::maybe_show_locus_as_html (const rich_location &richloc,
const source_printing_options &opts,
- diagnostic_t diagnostic_kind,
+ enum kind diagnostic_kind,
xml::printer &xp,
source_effect_info *effects,
html_label_writer *label_writer)
void
source_print_policy::print (pretty_printer &pp,
const rich_location &richloc,
- diagnostic_t diagnostic_kind,
+ enum kind diagnostic_kind,
source_effect_info *effects) const
{
layout layout (*this, richloc, effects);
colorizer col (pp, richloc, diagnostic_kind);
to_text sink (pp, col);
layout_printer<to_text> lp (sink, layout,
- diagnostic_kind == DK_DIAGNOSTIC_PATH);
+ diagnostic_kind == diagnostics::kind::path);
lp.print (*this);
}
void
source_print_policy::print_as_html (xml::printer &xp,
const rich_location &richloc,
- diagnostic_t diagnostic_kind,
+ enum kind diagnostic_kind,
source_effect_info *effects,
html_label_writer *label_writer) const
{
layout layout (*this, richloc, effects);
to_html sink (xp, &richloc, label_writer);
layout_printer<to_html> lp (sink, layout,
- diagnostic_kind == DK_DIAGNOSTIC_PATH);
+ diagnostic_kind == diagnostics::kind::path);
xml::auto_check_tag_nesting sentinel (xp);
lp.print (*this);
}
static std::unique_ptr<xml::node>
make_element_for_locus (const rich_location &rich_loc,
- diagnostic_t kind,
+ enum kind kind,
diagnostics::context &dc)
{
dc.m_last_location = UNKNOWN_LOCATION;
static label_text
make_raw_html_for_locus (const rich_location &rich_loc,
- diagnostic_t kind,
+ enum kind kind,
diagnostics::context &dc)
{
auto node = make_element_for_locus (rich_loc, kind, dc);
emoji_col));
layout test_layout (policy, richloc, nullptr);
colorizer col (*dc.get_reference_printer (),
- richloc, DK_ERROR);
+ richloc, diagnostics::kind::error);
diagnostics::to_text sink (*dc.get_reference_printer (), col);
layout_printer<diagnostics::to_text> lp (sink, test_layout, false);
lp.print (policy);
emoji_col + 2));
layout test_layout (dc, richloc, nullptr);
colorizer col (*dc.get_reference_printer (),
- richloc, DK_ERROR);
+ richloc, diagnostics::kind::error);
diagnostics::to_text sink (*dc.get_reference_printer (), col);
layout_printer<diagnostics::to_text> lp (sink, test_layout, false);
lp.print (policy);
diagnostics::source_print_policy policy (dc);
layout test_layout (policy, richloc, nullptr);
colorizer col (*dc.get_reference_printer (),
- richloc, DK_ERROR);
+ richloc, diagnostics::kind::error);
diagnostics::to_text sink (*dc.get_reference_printer (), col);
layout_printer<diagnostics::to_text> lp (sink, test_layout, false);
lp.print (policy);
diagnostics::source_print_policy policy (dc);
layout test_layout (policy, richloc, nullptr);
colorizer col (*dc.get_reference_printer (),
- richloc, DK_ERROR);
+ richloc, diagnostics::kind::error);
diagnostics::to_text sink (*dc.get_reference_printer (), col);
layout_printer<diagnostics::to_text> lp (sink, test_layout, false);
lp.print (policy);
{
test_context dc;
- auto out = make_raw_html_for_locus (richloc, DK_ERROR, dc);
+ auto out = make_raw_html_for_locus (richloc, diagnostics::kind::error, dc);
ASSERT_STREQ
("<table class=\"locus\">\n"
" <tbody class=\"line-span\">\n"
{
test_context dc;
dc.m_source_printing.show_line_numbers_p = true;
- auto out = make_raw_html_for_locus (richloc, DK_ERROR, dc);
+ auto out = make_raw_html_for_locus (richloc, diagnostics::kind::error, dc);
ASSERT_STREQ
("<table class=\"locus\">\n"
" <tbody class=\"line-span\">\n"
{
test_context dc;
dc.m_source_printing.show_line_numbers_p = true;
- auto out = make_raw_html_for_locus (richloc, DK_ERROR, dc);
+ auto out
+ = make_raw_html_for_locus (richloc, diagnostics::kind::error, dc);
ASSERT_STREQ
("<table class=\"locus\">\n"
" <tbody class=\"line-span\">\n"
text_sink::~text_sink ()
{
/* Some of the errors may actually have been warnings. */
- if (m_context.diagnostic_count (DK_WERROR))
+ if (m_context.diagnostic_count (kind::werror))
{
pretty_printer *pp = get_printer ();
/* -Werror was given. */
void
text_sink::on_report_diagnostic (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind)
+ enum kind orig_diag_kind)
{
pretty_printer *pp = get_printer ();
char *
text_sink::build_prefix (const diagnostic_info &diagnostic) const
{
- gcc_assert (diagnostic.m_kind < DK_LAST_DIAGNOSTIC_KIND);
+ gcc_assert (diagnostic.m_kind < kind::last_diagnostic_kind);
- const char *text = _(get_diagnostic_kind_text (diagnostic.m_kind));
+ const char *text = _(get_text_for_kind (diagnostic.m_kind));
const char *text_cs = "", *text_ce = "";
pretty_printer *pp = get_printer ();
- if (const char *color_name = diagnostic_get_color_for_kind (diagnostic.m_kind))
+ if (const char *color_name = get_color_for_kind (diagnostic.m_kind))
{
text_cs = colorize_start (pp_show_color (pp), color_name);
text_ce = colorize_stop (pp_show_color (pp));
/* Reduce verbosity of nested diagnostics by not printing "note: "
all the time. */
- if (diagnostic.m_kind == DK_NOTE)
+ if (diagnostic.m_kind == kind::note)
return indent_prefix;
char *result = build_message_string ("%s%s%s%s", indent_prefix,
rich_location richloc (line_table, location);
va_start (ap, gmsgid);
- diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_NOTE);
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, kind::note);
if (dc->m_inhibit_notes_p)
{
va_end (ap);
pp_set_prefix (pp, saved_prefix);
pp_newline (pp);
diagnostic_show_locus (dc, get_source_printing_options (),
- &richloc, DK_NOTE, pp);
+ &richloc, kind::note, pp);
va_end (ap);
}
pretty_printer * const pp = get_printer ();
char *saved_prefix = pp_take_prefix (pp);
pp_string (pp, " [");
- const char *kind_color = diagnostic_get_color_for_kind (diagnostic.m_kind);
+ const char *kind_color = get_color_for_kind (diagnostic.m_kind);
pp_string (pp, colorize_start (pp_show_color (pp), kind_color));
if (pp->supports_urls_p ())
{
pretty_printer * const pp = get_printer ();
char *saved_prefix = pp_take_prefix (pp);
pp_string (pp, " [");
- const char *kind_color
- = diagnostic_get_color_for_kind (diagnostic.m_kind);
+ const char *kind_color = get_color_for_kind (diagnostic.m_kind);
pp_string (pp, colorize_start (pp_show_color (pp), kind_color));
char *url = nullptr;
if (pp->supports_urls_p ())
void
text_sink::print_option_information (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind)
+ enum kind orig_diag_kind)
{
if (char *option_text
= m_context.make_option_name (diagnostic.m_option_id,
if (pp->supports_urls_p ())
option_url = m_context.make_option_url (diagnostic.m_option_id);
pp_string (pp, " [");
- const char *kind_color = diagnostic_get_color_for_kind (diagnostic.m_kind);
+ const char *kind_color = get_color_for_kind (diagnostic.m_kind);
pp_string (pp, colorize_start (pp_show_color (pp), kind_color));
if (option_url)
pp_begin_url (pp, option_url);
void
default_text_finalizer (text_sink &text_output,
const diagnostic_info *diagnostic,
- diagnostic_t)
+ enum kind)
{
pretty_printer *const pp = text_output.get_printer ();
char *saved_prefix = pp_take_prefix (pp);
void on_begin_group () override {}
void on_end_group () override {}
void on_report_diagnostic (const diagnostic_info &,
- diagnostic_t orig_diag_kind) override;
+ enum kind orig_diag_kind) override;
void on_report_verbatim (text_info &) final override;
void on_diagram (const diagram &d) override;
void after_diagnostic (const diagnostic_info &) override;
void print_any_cwe (const diagnostic_info &diagnostic);
void print_any_rules (const diagnostic_info &diagnostic);
void print_option_information (const diagnostic_info &diagnostic,
- diagnostic_t orig_diag_kind);
+ enum kind orig_diag_kind);
bool includes_seen_p (const line_map_ordinary *map);
const char *msg, va_list *ap)
{
diagnostic_info diagnostic;
- diagnostic_t dlevel;
+ enum diagnostics::kind dlevel;
bool save_warn_system_headers = global_dc->m_warn_system_headers;
bool ret;
global_dc->m_warn_system_headers = 1;
/* Fall through. */
case CPP_DL_WARNING:
- dlevel = DK_WARNING;
+ dlevel = diagnostics::kind::warning;
break;
case CPP_DL_PEDWARN:
- dlevel = DK_PEDWARN;
+ dlevel = diagnostics::kind::pedwarn;
break;
case CPP_DL_ERROR:
- dlevel = DK_ERROR;
+ dlevel = diagnostics::kind::error;
break;
case CPP_DL_ICE:
- dlevel = DK_ICE;
+ dlevel = diagnostics::kind::ice;
break;
case CPP_DL_NOTE:
- dlevel = DK_NOTE;
+ dlevel = diagnostics::kind::note;
break;
case CPP_DL_FATAL:
- dlevel = DK_FATAL;
+ dlevel = diagnostics::kind::fatal;
break;
default:
gcc_unreachable ();
global_dc->set_diagnostic_buffer (pp_warning_buffer);
diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
- DK_WARNING);
+ diagnostics::kind::warning);
diagnostic.m_option_id = opt;
bool ret = gfc_report_diagnostic (&diagnostic);
const char *color
= (loc_num
? "range1"
- : diagnostic_get_color_for_kind (curr_diagnostic->m_kind));
+ : diagnostics::get_color_for_kind (curr_diagnostic->m_kind));
pp_string (pp, colorize_start (pp_show_color (pp), color));
pp_string (pp, result[loc_num]);
pp_string (pp, colorize_stop (pp_show_color (pp)));
#undef DEFINE_DIAGNOSTIC_KIND
NULL
};
- gcc_assert (diagnostic->m_kind < DK_LAST_DIAGNOSTIC_KIND);
- const char *text = _(diagnostic_kind_text[diagnostic->m_kind]);
+ const int diag_kind_idx = static_cast<int> (diagnostic->m_kind);
+ gcc_assert (diagnostic->m_kind < diagnostics::kind::last_diagnostic_kind);
+ const char *text = _(diagnostic_kind_text[diag_kind_idx]);
const char *text_cs = "", *text_ce = "";
pretty_printer *const pp = context->get_reference_printer ();
- if (diagnostic_kind_color[diagnostic->m_kind])
+if (diagnostic_kind_color[diag_kind_idx])
{
text_cs = colorize_start (pp_show_color (pp),
- diagnostic_kind_color[diagnostic->m_kind]);
+ diagnostic_kind_color[diag_kind_idx]);
text_ce = colorize_stop (pp_show_color (pp));
}
return build_message_string ("%s%s:%s ", text_cs, text, text_ce);
static void
gfc_diagnostic_text_finalizer (diagnostics::text_sink &text_output,
const diagnostic_info *diagnostic ATTRIBUTE_UNUSED,
- diagnostic_t orig_diag_kind ATTRIBUTE_UNUSED)
+ enum diagnostics::kind orig_diag_kind ATTRIBUTE_UNUSED)
{
pretty_printer *const pp = text_output.get_printer ();
pp_destroy_prefix (pp);
bool ret;
va_start (argp, gmsgid);
- diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_WARNING);
+ diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
+ diagnostics::kind::warning);
diagnostic.m_option_id = opt;
ret = gfc_report_diagnostic (&diagnostic);
va_end (argp);
va_start (argp, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
- DK_WARNING);
+ diagnostics::kind::warning);
diagnostic.m_option_id = opt;
ret = gfc_report_diagnostic (&diagnostic);
va_end (argp);
va_start (argp, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
- DK_WARNING);
+ diagnostics::kind::warning);
diagnostic.m_option_id = opt;
ret = gfc_report_diagnostic (&diagnostic);
va_end (argp);
error_buffer->flag = true;
va_start (argp, gmsgid);
- diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_ERROR);
+ diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
+ diagnostics::kind::error);
gfc_report_diagnostic (&diagnostic);
va_end (argp);
}
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
va_start (argp, gmsgid);
- diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_FATAL);
+ diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
+ diagnostics::kind::fatal);
gfc_report_diagnostic (&diagnostic);
va_end (argp);
if (buffered_p)
global_dc->set_diagnostic_buffer (pp_error_buffer);
- diagnostic_set_info (&diagnostic, gmsgid, &argp, &richloc, DK_ERROR);
+ diagnostic_set_info (&diagnostic, gmsgid, &argp, &richloc,
+ diagnostics::kind::error);
gfc_report_diagnostic (&diagnostic);
if (buffered_p)
exit(EXIT_FAILURE);
va_start (argp, gmsgid);
- diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_ICE);
+ diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
+ diagnostics::kind::ice);
gfc_report_diagnostic (&diagnostic);
va_end (argp);
if (warn_line_truncation && !OPTION_SET_P (warnings_are_errors)
&& option_unspecified_p (OPT_Wline_truncation))
diagnostic_classify_diagnostic (global_dc, OPT_Wline_truncation,
- DK_ERROR, UNKNOWN_LOCATION);
+ diagnostics::kind::error,
+ UNKNOWN_LOCATION);
}
else
{
gcc_assert (opts == &global_options);
gcc_assert (opts_set == &global_options_set);
- gcc_assert (kind == DK_UNSPECIFIED);
+ gcc_assert (static_cast<diagnostics::kind> (kind)
+ == diagnostics::kind::unspecified);
gcc_assert (loc == UNKNOWN_LOCATION);
gcc_assert (dc == global_dc);
}
void on_report_diagnostic (const diagnostic_info &info,
- diagnostic_t orig_diag_kind) final override
+ enum diagnostics::kind orig_diag_kind) final override
{
JIT_LOG_SCOPE (gcc::jit::active_playback_ctxt->get_logger ());
static void
jit_end_diagnostic (diagnostics::text_sink &,
const diagnostic_info *,
- diagnostic_t)
+ enum diagnostics::kind)
{
gcc_assert (gcc::jit::active_playback_ctxt);
JIT_LOG_SCOPE (gcc::jit::active_playback_ctxt->get_logger ());
std::unique_ptr<diagnostic_execution_path> m_path;
};
-static diagnostic_t
-diagnostic_t_from_diagnostic_level (enum diagnostic_level level)
+static enum diagnostics::kind
+diagnostics_kind_from_diagnostic_level (enum diagnostic_level level)
{
switch (level)
{
default:
gcc_unreachable ();
case DIAGNOSTIC_LEVEL_ERROR:
- return DK_ERROR;
+ return diagnostics::kind::error;
case DIAGNOSTIC_LEVEL_WARNING:
- return DK_WARNING;
+ return diagnostics::kind::warning;
case DIAGNOSTIC_LEVEL_NOTE:
- return DK_NOTE;
+ return diagnostics::kind::note;
case DIAGNOSTIC_LEVEL_SORRY:
- return DK_SORRY;
+ return diagnostics::kind::sorry;
}
}
diagnostic_info info;
GCC_DIAGNOSTIC_PUSH_IGNORED(-Wsuggest-attribute=format)
diagnostic_set_info (&info, msgid, args, diag.get_rich_location (),
- diagnostic_t_from_diagnostic_level (diag.get_level ()));
+ diagnostics_kind_from_diagnostic_level
+ (diag.get_level ()));
GCC_DIAGNOSTIC_POP
info.m_metadata = diag.get_metadata ();
info.m_x_data = &diag;
return true;
}
char *make_option_name (diagnostics::option_id,
- diagnostic_t,
- diagnostic_t) const final override
+ enum diagnostics::kind,
+ enum diagnostics::kind) const final override
{
return nullptr;
}
rich_location richloc (line_table, location);
va_start (ap, message);
- diagnostic_set_info (&diagnostic, message, &ap, &richloc, DK_ERROR);
+ diagnostic_set_info (&diagnostic, message, &ap, &richloc,
+ diagnostics::kind::error);
diagnostic_report_diagnostic (global_dc, &diagnostic);
va_end (ap);
}
rich_location richloc (line_table, location);
va_start (ap, message);
- diagnostic_set_info (&diagnostic, message, &ap, &richloc, DK_WARNING);
+ diagnostic_set_info (&diagnostic, message, &ap, &richloc,
+ diagnostics::kind::warning);
diagnostic_report_diagnostic (global_dc, &diagnostic);
va_end (ap);
}
rich_location richloc (line_table, location);
va_start (ap, message);
- diagnostic_set_info (&diagnostic, message, &ap, &richloc, DK_NOTE);
+ diagnostic_set_info (&diagnostic, message, &ap, &richloc,
+ diagnostics::kind::note);
diagnostic_report_diagnostic (global_dc, &diagnostic);
va_end (ap);
}
/* rte_error_at - wraps up an error message. */
static void
-rte_error_at (location_t location, diagnostic_t kind, const char *message, ...)
+rte_error_at (location_t location, diagnostics::kind kind,
+ const char *message, ...)
{
diagnostic_info diagnostic;
va_list ap;
give the function context which might be misleading if this is inlined. */
static void
-generate_report (gimple *stmt, const char *report, diagnostic_t kind)
+generate_report (gimple *stmt, const char *report, diagnostics::kind kind)
{
if (gimple_call_num_args (stmt) == 5)
{
return message;
}
-/* error_message issue an DK_ERROR from grtenode. */
+/* error_message issue an diagnostics::kind::error from grtenode. */
void rtenode::error_message (void)
{
if (grtenode != NULL)
- generate_report (grtenode, "runtime error will occur", DK_ERROR);
+ generate_report (grtenode, "runtime error will occur",
+ diagnostics::kind::error);
}
-/* warning_message issue an DK_WARNING from grtenode. */
+/* warning_message issue an diagnostics::kind::warning from grtenode. */
void rtenode::warning_message (void)
{
("runtime error will occur if an exported procedure is called from %s",
"runtime error will occur if an exported procedure is called");
if (grtenode != NULL)
- generate_report (grtenode, message, DK_WARNING);
+ generate_report (grtenode, message, diagnostics::kind::warning);
}
-/* note_message issue an DK_NOTE from grtenode. */
+/* note_message issue an diagnostics::kind::note from grtenode. */
void rtenode::note_message (void)
{
if (grtenode != NULL)
- generate_report (grtenode, "runtime will occur if this procedure is called", DK_NOTE);
+ generate_report (grtenode, "runtime will occur if this procedure is called",
+ diagnostics::kind::note);
}
/* dump_vec display contents of vector array list. */
/* Handle option DECODED for the language indicated by LANG_MASK,
using the handlers in HANDLERS and setting fields in OPTS and
- OPTS_SET. KIND is the diagnostic_t if this is a diagnostics
- option, DK_UNSPECIFIED otherwise, and LOC is the location of the
- option for options from the source file, UNKNOWN_LOCATION
+ OPTS_SET. KIND is the enum diagnostics::kind if this is a diagnostics
+ option, diagnostics::kind::unspecified otherwise, and LOC is the location
+ of the option for options from the source file, UNKNOWN_LOCATION
otherwise. GENERATED_P is true for an option generated as part of
processing another option or otherwise generated internally, false
for one explicitly passed by the user. control_warning_option
gcc_assert (!decoded->errors);
- if (!handle_option (opts, opts_set, decoded, lang_mask, DK_UNSPECIFIED,
+ if (!handle_option (opts, opts_set, decoded, lang_mask,
+ static_cast<int> (diagnostics::kind::unspecified),
loc, handlers, false, dc))
error_at (loc, "unrecognized command-line option %qs", opt);
}
if (!flag_var)
return;
- if ((diagnostic_t) kind != DK_UNSPECIFIED && dc != NULL)
- diagnostic_classify_diagnostic (dc, opt_index, (diagnostic_t) kind, loc);
+ if ((enum diagnostics::kind) kind != diagnostics::kind::unspecified
+ && dc != nullptr)
+ diagnostic_classify_diagnostic (dc, opt_index,
+ (enum diagnostics::kind) kind, loc);
if (opts_set != NULL)
set_flag_var = option_flag_var (opt_index, opts_set);
if (opt_index == OPT_SPECIAL_ignore || opt_index == OPT_SPECIAL_warn_removed)
return;
if (dc)
- diagnostic_classify_diagnostic (dc, opt_index, (diagnostic_t) kind, loc);
+ diagnostic_classify_diagnostic (dc, opt_index,
+ static_cast<enum diagnostics::kind> (kind),
+ loc);
if (imply)
{
/* -Werror=foo implies -Wfoo. */
}
int option_enabled_p (diagnostics::option_id option_id) const final override;
- char *make_option_name (diagnostics::option_id option_id,
- diagnostic_t orig_diag_kind,
- diagnostic_t diag_kind) const final override;
+ char *
+ make_option_name (diagnostics::option_id option_id,
+ enum diagnostics::kind orig_diag_kind,
+ enum diagnostics::kind diag_kind) const final override;
private:
const diagnostics::context &m_context;
diagnostics::context *dc, void (*) (void))
{
gcc_assert (dc == global_dc);
- gcc_assert (kind == DK_UNSPECIFIED);
+ gcc_assert (static_cast<diagnostics::kind> (kind)
+ == diagnostics::kind::unspecified);
return targetm_common.handle_option (opts, opts_set, decoded, loc);
}
if (enabled)
handle_generated_option (opts, opts_set, default_opt->opt_index,
default_opt->arg, default_opt->value,
- lang_mask, DK_UNSPECIFIED, loc,
+ lang_mask,
+ static_cast<int> (diagnostics::kind::unspecified),
+ loc,
handlers, true, dc);
else if (default_opt->arg == NULL
&& !option->cl_reject_negative
&& !(option->flags & CL_PARAMS))
handle_generated_option (opts, opts_set, default_opt->opt_index,
default_opt->arg, !default_opt->value,
- lang_mask, DK_UNSPECIFIED, loc,
+ lang_mask,
+ static_cast<int> (diagnostics::kind::unspecified),
+ loc,
handlers, true, dc);
}
case OPT_pedantic_errors:
dc->m_pedantic_errors = 1;
- control_warning_option (OPT_Wpedantic, DK_ERROR, NULL, value,
+ control_warning_option (OPT_Wpedantic,
+ static_cast<int> (diagnostics::kind::error),
+ NULL, value,
loc, lang_mask,
handlers, opts, opts_set,
dc);
"controls warnings", arg, new_option);
else
{
- const diagnostic_t kind = value ? DK_ERROR : DK_WARNING;
+ const enum diagnostics::kind kind = (value
+ ? diagnostics::kind::error
+ : diagnostics::kind::warning);
const char *arg = NULL;
if (cl_options[option_index].flags & CL_JOINED)
char *
compiler_diagnostic_option_manager::
make_option_name (diagnostics::option_id option_id,
- diagnostic_t orig_diag_kind,
- diagnostic_t diag_kind) const
+ enum diagnostics::kind orig_diag_kind,
+ enum diagnostics::kind diag_kind) const
{
if (option_id.m_idx)
{
/* A warning classified as an error. */
- if ((orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN)
- && diag_kind == DK_ERROR)
+ if ((orig_diag_kind == diagnostics::kind::warning
+ || orig_diag_kind == diagnostics::kind::pedwarn)
+ && diag_kind == diagnostics::kind::error)
return concat (cl_options[OPT_Werror_].opt_text,
/* Skip over "-W". */
cl_options[option_id.m_idx].opt_text + 2,
return xstrdup (cl_options[option_id.m_idx].opt_text);
}
/* A warning without option classified as an error. */
- else if ((orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN
- || diag_kind == DK_WARNING)
+ else if ((orig_diag_kind == diagnostics::kind::warning
+ || orig_diag_kind == diagnostics::kind::pedwarn
+ || diag_kind == diagnostics::kind::warning)
&& m_context.warning_as_error_requested_p ())
return xstrdup (cl_options[OPT_Werror].opt_text);
else
static location_t location_for_asm (const rtx_insn *);
static void diagnostic_for_asm (const rtx_insn *, const char *, va_list *,
- diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0);
+ enum diagnostics::kind) ATTRIBUTE_GCC_DIAG(2,0);
/* Figure the location of the given INSN. */
static location_t
and each ASM_OPERANDS records its own source file and line. */
static void
diagnostic_for_asm (const rtx_insn *insn, const char *msg, va_list *args_ptr,
- diagnostic_t kind)
+ enum diagnostics::kind kind)
{
diagnostic_info diagnostic;
rich_location richloc (line_table, location_for_asm (insn));
va_list ap;
va_start (ap, gmsgid);
- diagnostic_for_asm (insn, gmsgid, &ap, DK_ERROR);
+ diagnostic_for_asm (insn, gmsgid, &ap, diagnostics::kind::error);
va_end (ap);
}
va_list ap;
va_start (ap, gmsgid);
- diagnostic_for_asm (insn, gmsgid, &ap, DK_WARNING);
+ diagnostic_for_asm (insn, gmsgid, &ap, diagnostics::kind::warning);
va_end (ap);
}
/* Print an error message for invalid use of an incomplete type.
VALUE is the expression that was used (or 0 if that isn't known)
and TYPE is the type that was invalid. DIAG_KIND indicates the
- type of diagnostic (see diagnostic.def). */
+ type of diagnostic (see diagnostics/kinds.def). */
void
cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
- const_tree type, diagnostic_t diag_kind)
+ const_tree type,
+ enum diagnostics::kind diag_kind)
{
// bool is_decl = false, complained = false;
- gcc_assert (diag_kind == DK_WARNING || diag_kind == DK_PEDWARN
- || diag_kind == DK_ERROR);
+ gcc_assert (diag_kind == diagnostics::kind::warning
+ || diag_kind == diagnostics::kind::pedwarn
+ || diag_kind == diagnostics::kind::error);
/* Avoid duplicate error message. */
if (TREE_CODE (type) == ERROR_MARK)
else if (!COMPLETE_TYPE_P (type))
{
if (complain & tf_error)
- cxx_incomplete_type_diagnostic (value, type, DK_ERROR);
+ cxx_incomplete_type_diagnostic (value, type, diagnostics::kind::error);
note_failed_type_completion_for_satisfaction (type);
return NULL_TREE;
}
extern tree resolve_nondeduced_context (tree, tsubst_flags_t);
extern void cxx_incomplete_type_diagnostic (location_t, const_tree, const_tree,
- diagnostic_t);
+ enum diagnostics::kind);
extern void cxx_incomplete_type_error (location_t, const_tree, const_tree);
inline void
cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
- diagnostic_t diag_kind)
+ enum diagnostics::kind diag_kind)
{
cxx_incomplete_type_diagnostic (rs_expr_loc_or_input_loc (value), value, type,
diag_kind);
inline void
cxx_incomplete_type_error (const_tree value, const_tree type)
{
- cxx_incomplete_type_diagnostic (value, type, DK_ERROR);
+ cxx_incomplete_type_diagnostic (value, type, diagnostics::kind::error);
}
extern location_t
and use the lower-level emit_diagnostic () instead of the more common
internal_error_no_backtrace () in order to pass our locus. */
diagnostics::text_finalizer (global_dc) = funny_ice_text_finalizer;
- emit_diagnostic (DK_ICE_NOBT, expr.get_locus (), -1,
+ emit_diagnostic (diagnostics::kind::ice_nobt, expr.get_locus (), -1,
"are you trying to break %s? how dare you?",
expr.as_string ().c_str ());
}
void ATTRIBUTE_NORETURN
funny_ice_text_finalizer (diagnostics::text_sink &text_output,
const diagnostic_info *diagnostic,
- diagnostic_t diag_kind)
+ enum diagnostics::kind diag_kind)
{
- gcc_assert (diag_kind == DK_ICE_NOBT);
+ gcc_assert (diag_kind == diagnostics::kind::ice_nobt);
diagnostics::default_text_finalizer (text_output, diagnostic, diag_kind);
fnotice (stderr, "You have broken GCC Rust. This is a feature.\n");
exit (ICE_EXIT_CODE);
void ATTRIBUTE_NORETURN
funny_ice_text_finalizer (diagnostics::text_sink &text_output,
const diagnostic_info *diagnostic,
- diagnostic_t diag_kind);
+ enum diagnostics::kind diag_kind);
} // namespace Resolver
} // namespace Rust
else if (funny_error)
{
diagnostics::text_finalizer (global_dc) = Resolver::funny_ice_text_finalizer;
- emit_diagnostic (DK_ICE_NOBT, expr.get_locus (), -1,
+ emit_diagnostic (diagnostics::kind::ice_nobt, expr.get_locus (), -1,
"are you trying to break %s? how dare you?",
expr.as_string ().c_str ());
}
const char *text = ngettext (singular_gmsgid, plural_gmsgid, gtn);
diagnostic_set_info_translated (&diagnostic, text, ap, &richloc,
- DK_WARNING);
+ diagnostics::kind::warning);
}
else
diagnostic_set_info (&diagnostic, singular_gmsgid, ap, &richloc,
- DK_WARNING);
+ diagnostics::kind::warning);
diagnostic.m_option_id = option_id;
bool warned = diagnostic_report_diagnostic (global_dc, &diagnostic);
static void
custom_diagnostic_text_finalizer (diagnostics::text_sink &text_output,
const diagnostic_info *diagnostic,
- diagnostic_t)
+ enum diagnostics::kind)
{
pretty_printer *const pp = text_output.get_printer ();
bool old_show_color = pp_show_color (pp);
/* Run the diagnostic and fix-it printing code. */
diagnostics::selftest::test_context dc;
diagnostic_show_locus (&dc, dc.m_source_printing,
- richloc, DK_ERROR, dc.get_reference_printer ());
+ richloc, diagnostics::kind::error,
+ dc.get_reference_printer ());
/* Generate a diff. */
diagnostics::changes::change_set edit (global_dc->get_file_cache ());
static void
verify_unpacked_ranges (diagnostics::text_sink &text_output,
const diagnostic_info *diagnostic,
- diagnostic_t orig_diag_kind)
+ enum diagnostics::kind orig_diag_kind)
{
/* Verify that the locations are ad-hoc, not packed. */
location_t loc = diagnostic_location (diagnostic);
static void
verify_no_columns (diagnostics::text_sink &text_output,
const diagnostic_info *diagnostic,
- diagnostic_t orig_diag_kind)
+ enum diagnostics::kind orig_diag_kind)
{
/* Verify that the locations have no columns. */
location_t loc = diagnostic_location (diagnostic);
}
# Look for messages with 'note: ' prefixes.
-# In addition to standard compiler diagnostics ('DK_NOTE', 'inform' functions,
-# "for additional details on an error message"),
+# In addition to standard compiler diagnostics (diagnostics::kind::note,
+# 'inform' functions, "for additional details on an error message"),
# this also includes output from '-fopt-info' for 'MSG_NOTE':
# a general optimization info.
# By default, any *excess* notes are pruned, meaning their appearance doesn't
if (warn_coverage_mismatch
&& option_unspecified_p (OPT_Wcoverage_mismatch))
diagnostic_classify_diagnostic (global_dc, OPT_Wcoverage_mismatch,
- DK_ERROR, UNKNOWN_LOCATION);
+ diagnostics::kind::error,
+ UNKNOWN_LOCATION);
if (warn_coverage_invalid_linenum
&& option_unspecified_p (OPT_Wcoverage_invalid_line_number))
diagnostic_classify_diagnostic (global_dc, OPT_Wcoverage_invalid_line_number,
- DK_ERROR, UNKNOWN_LOCATION);
+ diagnostics::kind::error,
+ UNKNOWN_LOCATION);
}
/* Save the current optimization options. */
zero of said file. */
location_t main_loc;
- /* If non-zero, override diagnostic locations (other than DK_NOTE
- diagnostics) to this one. */
+ /* If non-zero, override diagnostic locations (other than
+ diagnostics::kind::note diagnostics) to this one. */
location_t diagnostic_override_loc;
/* Returns true iff we should warn about UTF-8 bidirectional control