]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: convert diagnostic_t to enum class diagnostics::kind
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 25 Jul 2025 19:13:43 +0000 (15:13 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 25 Jul 2025 19:13:43 +0000 (15:13 -0400)
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>
80 files changed:
gcc/Makefile.in
gcc/ada/gcc-interface/trans.cc
gcc/analyzer/pending-diagnostic.cc
gcc/analyzer/program-point.cc
gcc/c-family/c-common.cc
gcc/c-family/c-format.cc
gcc/c-family/c-lex.cc
gcc/c-family/c-opts.cc
gcc/c-family/c-pragma.cc
gcc/c-family/c-warn.cc
gcc/c/c-errors.cc
gcc/c/c-parser.cc
gcc/c/c-typeck.cc
gcc/cobol/util.cc
gcc/config/aarch64/aarch64.cc
gcc/config/i386/i386-options.cc
gcc/config/s390/s390.cc
gcc/cp/call.cc
gcc/cp/constexpr.cc
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/error.cc
gcc/cp/init.cc
gcc/cp/method.cc
gcc/cp/module.cc
gcc/cp/parser.cc
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/cp/typeck.cc
gcc/cp/typeck2.cc
gcc/d/d-diagnostic.cc
gcc/diagnostic-core.h
gcc/diagnostic-global-context.cc
gcc/diagnostic.cc
gcc/diagnostic.h
gcc/diagnostics/buffering.cc
gcc/diagnostics/buffering.h
gcc/diagnostics/context.h
gcc/diagnostics/diagnostic-info.h
gcc/diagnostics/html-sink.cc
gcc/diagnostics/kinds.def [moved from gcc/diagnostic.def with 53% similarity]
gcc/diagnostics/kinds.h [new file with mode: 0644]
gcc/diagnostics/lazy-paths.cc
gcc/diagnostics/option-classifier.cc
gcc/diagnostics/option-classifier.h
gcc/diagnostics/output-spec.h
gcc/diagnostics/paths-output.cc
gcc/diagnostics/sarif-sink.cc
gcc/diagnostics/selftest-context.cc
gcc/diagnostics/selftest-context.h
gcc/diagnostics/sink.h
gcc/diagnostics/source-printing.cc
gcc/diagnostics/text-sink.cc
gcc/diagnostics/text-sink.h
gcc/fortran/cpp.cc
gcc/fortran/error.cc
gcc/fortran/options.cc
gcc/gcc.cc
gcc/jit/dummy-frontend.cc
gcc/libgdiagnostics.cc
gcc/lto-wrapper.cc
gcc/m2/gm2-gcc/m2linemap.cc
gcc/m2/gm2-gcc/rtegraph.cc
gcc/opts-common.cc
gcc/opts-diagnostic.h
gcc/opts.cc
gcc/rtl-error.cc
gcc/rust/backend/rust-tree.cc
gcc/rust/backend/rust-tree.h
gcc/rust/resolve/rust-ast-resolve-expr.cc
gcc/rust/resolve/rust-ice-finalizer.cc
gcc/rust/resolve/rust-ice-finalizer.h
gcc/rust/resolve/rust-late-name-resolver-2.0.cc
gcc/substring-locations.cc
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc
gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc
gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.cc
gcc/testsuite/lib/gcc-dg.exp
gcc/toplev.cc
libcpp/internal.h

index 5b33951440d60116e6c88bb078800c6659e1f333..378b9143045effea07e4e9b4ade35995b3ff9fc5 100644 (file)
@@ -1069,7 +1069,7 @@ TREE_SSA_H = tree-ssa.h tree-ssa-operands.h \
 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)
index cd480efd6f236a0d11a703357775b862cb66b190..ef5ec7598ef4c5e9b7a54aea85dcbbd6711ad3de 100644 (file)
@@ -1510,7 +1510,7 @@ Pragma_to_gnu (Node_Id gnat_node)
        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));
@@ -1521,12 +1521,12 @@ Pragma_to_gnu (Node_Id 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;
 
@@ -1543,11 +1543,11 @@ Pragma_to_gnu (Node_Id gnat_node)
            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:
@@ -1569,7 +1569,7 @@ Pragma_to_gnu (Node_Id gnat_node)
                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
index 20312d4d21d6a15f61ba6c298452001388d51869..cc2d7959c4cc5a4d1ac49457e0fcb0526c3aa11f 100644 (file)
@@ -92,7 +92,7 @@ diagnostic_emission_context::warn (const char *gmsgid, ...)
   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);
@@ -110,7 +110,7 @@ diagnostic_emission_context::inform (const char *gmsgid, ...)
   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);
index 1d5d65c5cc403b523a82ee3aab1082557f9ea3a3..a07d3c80a34dbdc82035bd81fa5d2974eb46573a 100644 (file)
@@ -265,7 +265,7 @@ function_point::print_source_line (pretty_printer *pp) const
   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 ()));
 }
 
index 5e9fa659bed8e11a6df5a5b5324c69b4340d4cec..a9f2dc44210424710510ad51ceab0e0d01f5122f 100644 (file)
@@ -7068,7 +7068,7 @@ c_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
                  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;
 
@@ -7082,24 +7082,24 @@ c_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
     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 ();
index 04b5b23936bd7ffeb054f0a83104c74ebf649151..6934087ce5c323d6868da538dc9bde352386439d 100644 (file)
@@ -5587,7 +5587,9 @@ test_type_mismatch_range_labels ()
   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"
index fef6ae6f457b38466ebac220339ad86ccf718334..b45d7228c5d261f11d12a452f7600ab2c5121f6e 100644 (file)
@@ -1176,7 +1176,7 @@ interpret_integer (const cpp_token *token, unsigned int flags,
          && (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"
index 05985ea084af9e047c616177a6a9f4eb47434701..d256ea60444581a28411cdc4e4924cb5088a6632 100644 (file)
@@ -171,7 +171,7 @@ c_common_option_lang_mask (void)
 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);
index 137b83bf5b15956fd76e5cab58ef8b4c2c12434f..8a1218bce71fcb7c7c9b760bc1b240ee4304a9e3 100644 (file)
@@ -781,7 +781,7 @@ public:
       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;
@@ -792,7 +792,7 @@ public:
     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;
   }
@@ -808,7 +808,7 @@ public:
     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)
@@ -818,17 +818,17 @@ public:
     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;
       }
   }
 
@@ -1016,7 +1016,8 @@ handle_pragma_diagnostic_impl ()
      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);
index d547b08f55daaaca6389b4aeedf9c01a374e6939..09517d28ba11fda9678ffbd955d985cf6605be7e 100644 (file)
@@ -3835,7 +3835,7 @@ do_warn_array_compare (location_t location, tree_code code, tree op0, tree op1)
     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)
     {
@@ -3843,7 +3843,7 @@ do_warn_array_compare (location_t location, tree_code code, tree op0, tree op1)
       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");
index e91cafba56be90e276e1b00301870b80d44f4b75..39ec1304766d1e8deee20be9ecbf9ad935948dea 100644 (file)
@@ -48,7 +48,8 @@ pedwarn_c23 (location_t location,
     {
       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);
     }
@@ -58,7 +59,8 @@ pedwarn_c23 (location_t location,
   /* 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);
     }
@@ -93,7 +95,8 @@ pedwarn_c11 (location_t location,
     {
       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
@@ -106,7 +109,8 @@ pedwarn_c11 (location_t location,
   /* 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);
     }
@@ -137,7 +141,8 @@ pedwarn_c99 (location_t location,
     {
       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);
     }
@@ -147,7 +152,8 @@ pedwarn_c99 (location_t location,
   /* 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);
     }
@@ -183,7 +189,8 @@ pedwarn_c90 (location_t location,
        {
          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;
@@ -196,7 +203,8 @@ pedwarn_c90 (location_t location,
     {
       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);
     }
@@ -206,7 +214,8 @@ pedwarn_c90 (location_t location,
   /* 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;
index 5119841a589522ed0904aa21961f9475994fe5a2..4a13fc0d384214696dd326b7d768377b3de1f23d 100644 (file)
@@ -29162,11 +29162,14 @@ c_parser_omp_error (c_parser *parser, enum pragma_context context)
       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;
 }
index e022e61c6b197fc5d7863c31c5928856efd4a6d1..ed6e56e72792ee86310d04b12ed3c490480dcc57 100644 (file)
@@ -6433,14 +6433,16 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
       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"))
@@ -7598,7 +7600,8 @@ error_init (location_t loc, const char *gmsgid, ...)
   /* 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));
@@ -7610,7 +7613,7 @@ error_init (location_t loc, const char *gmsgid, ...)
 
 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
@@ -7637,7 +7640,8 @@ pedwarn_init (location_t loc, int opt, const char *gmsgid, ...)
 {
   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;
 }
@@ -7649,7 +7653,8 @@ permerror_init (location_t loc, int opt, const char *gmsgid, ...)
 {
   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;
 }
@@ -12891,7 +12896,9 @@ c_finish_return (location_t loc, tree retval, tree origtype, bool musttail_p)
          && 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"))
index 81864100eaac5290bc219b1c3a2376ed56c2b5de..2a7bf2ba86d01cc8a98a4648b33db6d61ec44433 100644 (file)
@@ -2168,7 +2168,8 @@ ydferror( const char gmsgid[], ... ) {
   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);
 }
 
@@ -2223,7 +2224,8 @@ class temp_loc_t {
   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();
 
@@ -2247,7 +2249,8 @@ warn_msg( const YYLTYPE& loc, const char gmsgid[], ... ) {
   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;
@@ -2259,7 +2262,8 @@ void error_msg_direct( const char gmsgid[], ... ) {
   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);
 }
@@ -2277,7 +2281,7 @@ yyerror( const char gmsgid[], ... ) {
                                               nullptr,
                                               option_zero,
                                               gmsgid,
-                                              &ap, DK_ERROR);
+                                              &ap, diagnostics::kind::error);
   va_end (ap);
   global_dc->end_group();
 }
@@ -2288,7 +2292,7 @@ yywarn( const char gmsgid[], ... ) {
   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;
@@ -2486,7 +2490,8 @@ cbl_internal_error(const char *gmsgid, ...) {
   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.
@@ -2498,7 +2503,8 @@ cbl_unimplementedw(const char *gmsgid, ...) {
   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);
 }
 
@@ -2508,7 +2514,8 @@ cbl_unimplemented(const char *gmsgid, ...) {
   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);
 }
 
@@ -2519,7 +2526,8 @@ cbl_unimplemented_at( const YYLTYPE& loc, const char *gmsgid, ... ) {
   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);
 }
 
@@ -2536,7 +2544,8 @@ cbl_err(const char *fmt, ...) {
   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
@@ -2547,7 +2556,8 @@ cbl_errx(const char *gmsgid, ...) {
   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);
   }
 
index 2871b5f6e002d19b5f746b56a6d769f91093817f..4d9d83dfa883bfdd0631107de3856aa8dc651aa0 100644 (file)
@@ -19967,8 +19967,9 @@ aarch64_process_one_target_attr (char *arg_str)
              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
                {
index d244b225afeeb09b9974a4d12a5d0a51a14565a2..ca6bb836ab08a024c30f5098e917c4e43672ee4c 100644 (file)
@@ -1362,7 +1362,9 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
          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
            {
index f257ea57440f566c61bf13cfb363598adb607315..abe551cfdc4cacbf08b603941f011e4b6e8ba0a1 100644 (file)
@@ -16874,8 +16874,9 @@ s390_valid_target_attribute_inner_p (tree args,
              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
            {
@@ -16892,8 +16893,9 @@ s390_valid_target_attribute_inner_p (tree args,
          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);
index 0f3143375261abfa5ea98b49c88362a7bcab5334..9283d974966c0debc755e18fae3221a4e201abe3 100644 (file)
@@ -220,7 +220,8 @@ static void add_candidates (tree, tree, const vec<tree, va_gc> *, tree, tree,
                            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 *);
@@ -6460,7 +6461,9 @@ build_conditional_expr (const op_location_t &loc,
               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);
@@ -7647,8 +7650,9 @@ build_new_op (const op_location_t &loc, enum tree_code code, int flags,
                      && (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);
@@ -8462,11 +8466,11 @@ complain_about_access (tree decl, tree diag_decl, tree diag_location,
 
 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
@@ -8490,9 +8494,9 @@ build_temp (tree expr, tree type, int flags,
   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;
 }
 
@@ -8704,7 +8708,7 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
                       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);
@@ -9242,7 +9246,7 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
       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);
index b83d3701926b264684e2c6f257a0b014bf952a36..202d64b21431f67db8837da8804e407d62f3085b 100644 (file)
@@ -161,13 +161,16 @@ constexpr_error (location_t location, bool constexpr_fundef_p,
   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);
     }
index bafda3b38ccfab3a7c7d412c2a686f5a7ac9055e..e3bfed0ef567d319fe1660cb664e186164cc1a88 100644 (file)
@@ -8652,7 +8652,7 @@ extern void maybe_warn_pessimizing_move        (tree, tree, bool);
 /* 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)
 {
@@ -8700,7 +8700,7 @@ cp_expr_loc_or_input_loc (const_tree t)
 
 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);
@@ -8711,7 +8711,7 @@ extern void cxx_incomplete_type_error             (location_t, const_tree,
 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);
index 82af7100c5c9d60252f0e7be73ad1c55de7f542b..cb3ebfff429820c675731623cb01d95b005152bb 100644 (file)
@@ -110,7 +110,7 @@ static void initialize_local_var (tree, tree, bool);
 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.
@@ -3737,10 +3737,10 @@ decl_jump_unsafe (tree decl)
 
 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")
@@ -3776,7 +3776,8 @@ check_previous_goto_1 (tree decl, cp_binding_level* level, tree names,
 
   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");
@@ -3798,7 +3799,8 @@ check_previous_goto_1 (tree decl, cp_binding_level* level, tree names,
 
          if (!identified)
            {
-             complained = identify_goto (decl, input_location, locus, DK_ERROR,
+             complained = identify_goto (decl, input_location, locus,
+                                         diagnostics::kind::error,
                                          computed);
              identified = 2;
            }
@@ -3866,7 +3868,8 @@ check_previous_goto_1 (tree decl, cp_binding_level* level, tree names,
       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)
@@ -3877,7 +3880,8 @@ check_previous_goto_1 (tree decl, cp_binding_level* level, tree names,
   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)
@@ -3949,14 +3953,14 @@ check_goto_1 (named_label_entry *ent, bool computed)
       || 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)
@@ -3969,7 +3973,9 @@ check_goto_1 (named_label_entry *ent, bool computed)
          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)
@@ -4013,7 +4019,8 @@ check_goto_1 (named_label_entry *ent, bool computed)
              {
                complained = identify_goto (decl,
                                            DECL_SOURCE_LOCATION (decl),
-                                           &input_location, DK_ERROR,
+                                           &input_location,
+                                           diagnostics::kind::error,
                                            computed);
                identified = 2;
              }
@@ -4037,7 +4044,8 @@ check_goto_1 (named_label_entry *ent, bool computed)
                {
                  complained
                    = identify_goto (decl, DECL_SOURCE_LOCATION (decl),
-                                    &input_location, DK_ERROR, computed);
+                                    &input_location, diagnostics::kind::error,
+                                    computed);
                  identified = 2;
                }
              if (complained)
@@ -4053,7 +4061,8 @@ check_goto_1 (named_label_entry *ent, bool computed)
                    {
                      complained
                        = identify_goto (decl, DECL_SOURCE_LOCATION (decl),
-                                        &input_location, DK_ERROR, computed);
+                                        &input_location, diagnostics::kind::error,
+                                        computed);
                      identified = 2;
                    }
                  if (complained)
@@ -11275,12 +11284,12 @@ grokfndecl (tree ctype,
           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)
@@ -17397,7 +17406,8 @@ xref_basetypes (tree ref, tree base_list)
         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.  */
index f40f35781eb6b8b4793c0f937d8f94ad44f22de6..814aa07bc4b0171d02191cb45aff3d6492936ffd 100644 (file)
@@ -253,13 +253,13 @@ static void
 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
@@ -4030,7 +4030,7 @@ public:
            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);
          }
       }
@@ -4042,7 +4042,7 @@ public:
        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);
       }
   }
@@ -4939,7 +4939,9 @@ pedwarn_cxx98 (location_t location,
 
   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);
index 0a389fb6ecde43f0255110fe9e01f577b5bfaa59..09fb4f365522e88c789f169e2e7f3d7d727ce552 100644 (file)
@@ -4181,7 +4181,8 @@ build_vec_delete_1 (location_t loc, tree base, tree maxindex, tree type,
                          "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");
@@ -5286,7 +5287,8 @@ build_delete (location_t loc, tree otype, tree addr,
                                  "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 "
index 22a84b9c11a139313207164b448b6f056073b1ed..62f8d80c7814658d51c07e53bc3071974896a9f4 100644 (file)
@@ -1187,15 +1187,15 @@ early_check_defaulted_comparison (tree fn)
   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;
     }
 
@@ -3688,21 +3688,24 @@ maybe_delete_defaulted_fn (tree fn, tree implicit_fn)
              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;
index d125c33877d1d536daadd105b34e3883b30026bc..42a1979ac510684989c178afd2ad3e2686d3972e 100644 (file)
@@ -18338,22 +18338,23 @@ module_state::write_ordinary_maps (elf_out *to, range_t &info,
 /* 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),
@@ -18380,9 +18381,10 @@ module_state::write_diagnostic_classification (elf_out *to,
   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);
@@ -18415,10 +18417,10 @@ module_state::write_diagnostic_classification (elf_out *to,
       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);
        }
     }
@@ -18453,8 +18455,8 @@ module_state::read_diagnostic_classification (diagnostics::context *dc)
     {
       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 });
@@ -18469,7 +18471,7 @@ module_state::read_diagnostic_classification (diagnostics::context *dc)
        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)
          {
@@ -18486,7 +18488,7 @@ module_state::read_diagnostic_classification (diagnostics::context *dc)
       /* 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);
     }
 
index 0d9ed2ea82b1519a75a21b16d6768ce43479cbb4..9e9cd9be54d1bf41719a2784433ff46d1058e360 100644 (file)
@@ -5266,7 +5266,7 @@ cp_parser_userdef_numeric_literal (cp_parser *parser)
              && (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)
@@ -5276,7 +5276,7 @@ cp_parser_userdef_numeric_literal (cp_parser *parser)
       if (cxlit == error_mark_node)
        {
          /* No <complex>, so pedwarn and use GNU semantics.  */
-         kind = DK_PEDWARN;
+         kind = diagnostics::kind::pedwarn;
          opt = OPT_Wpedantic;
        }
     }
@@ -5303,7 +5303,7 @@ cp_parser_userdef_numeric_literal (cp_parser *parser)
              "to enable more built-in suffixes");
   }
 
-  if (kind == DK_ERROR)
+  if (kind == diagnostics::kind::error)
     value = error_mark_node;
   else
     {
@@ -6647,7 +6647,8 @@ cp_parser_primary_expression (cp_parser *parser,
    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;
@@ -8854,8 +8855,10 @@ cp_parser_dot_deref_incomplete (tree *scope, cp_expr *postfix_expression,
 {
   /* 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))
     {
@@ -8867,27 +8870,27 @@ cp_parser_dot_deref_incomplete (tree *scope, cp_expr *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)
     {
@@ -9510,7 +9513,7 @@ cp_parser_unary_expression (cp_parser *parser, cp_id_kind * pidk,
            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.  */
@@ -33706,7 +33709,9 @@ cp_parser_constructor_declarator_p (cp_parser *parser, cp_parser_flags flags,
       && 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", "< >");
@@ -53048,11 +53053,14 @@ cp_parser_omp_error (cp_parser *parser, cp_token *pragma_tok,
       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;
 }
index fd23be1fe26299f048b8fd69b6a98c90ab88ba3e..71ae764ce8d9a1eb1d07c4dba4ccf5cb50a04764 100644 (file)
@@ -31647,7 +31647,9 @@ do_class_deduction (tree ptype, tree tmpl, tree init, tree outer_targs,
          /* 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 "
index ee77d31f0976b4c881fced11403da82d41b1c331..52ecac4e4cc6b0f9a0d1c67a5097b78264e50edf 100644 (file)
@@ -13691,7 +13691,8 @@ check_trait_type (tree type, int kind = 1)
 
   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;
index a66586dfad8264d736eb488fc2769158a70fa769..f592894e01ab0fea6eee929510f9ffd6e32d11e7 100644 (file)
@@ -155,7 +155,7 @@ complete_type_or_maybe_complain (tree type, tree value, tsubst_flags_t complain)
   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;
     }
@@ -618,7 +618,7 @@ type_after_usual_arithmetic_conversions (tree t1, tree t2)
 
 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)
@@ -690,7 +690,7 @@ composite_pointer_type_r (const op_location_t &location,
   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;
@@ -716,7 +716,7 @@ composite_pointer_type_r (const op_location_t &location,
                        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;
@@ -851,7 +851,8 @@ composite_pointer_type (const op_location_t &location,
       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;
         }
     }
@@ -10805,7 +10806,9 @@ maybe_warn_about_returning_address_of_local (tree retval, location_t loc)
     {
       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))
index 97852d3c72762487a2383c50dd514c1aac3b4ade..faaf1df6158345d3b2eba4751e47bc5ba1498120 100644 (file)
@@ -295,11 +295,12 @@ cxx_incomplete_type_inform (const_tree type)
 /* 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;
 
@@ -445,7 +446,7 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
 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
@@ -2632,7 +2633,7 @@ add_exception_specifier (tree list, tree spec, tsubst_flags_t complain)
   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;
@@ -2664,7 +2665,7 @@ add_exception_specifier (tree list, tree spec, tsubst_flags_t complain)
         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)
@@ -2678,9 +2679,9 @@ add_exception_specifier (tree list, tree spec, tsubst_flags_t complain)
        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);
 
index f7e380b1119abd75220364ed81bab59e5c287747..44749344ce4868e079eda9c344c6c81da422cc81 100644 (file)
@@ -185,7 +185,7 @@ escape_d_format (const char *format)
 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);
@@ -224,7 +224,7 @@ void D_ATTRIBUTE_FORMAT(2,0) ATTRIBUTE_GCC_DIAG(2,0)
 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;
@@ -238,7 +238,9 @@ verrorReport (const SourceLoc loc, const char *format, va_list ap,
       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)
     {
@@ -254,7 +256,7 @@ verrorReport (const SourceLoc loc, const char *format, va_list ap,
       if (global.params.useWarnings == DIAGNOSTICerror)
        global.warnings++;
 
-      diag_kind = DK_WARNING;
+      diag_kind = diagnostics::kind::warning;
     }
   else if (kind == ErrorKind::deprecation)
     {
@@ -270,11 +272,11 @@ verrorReport (const SourceLoc loc, const char *format, va_list ap,
        }
 
       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)
@@ -282,7 +284,7 @@ verrorReport (const SourceLoc loc, const char *format, va_list ap,
       if (global.gag)
        return;
 
-      diag_kind = DK_DEBUG;
+      diag_kind = diagnostics::kind::debug;
       verbatim = true;
     }
   else
@@ -328,7 +330,8 @@ verrorReportSupplemental (const SourceLoc loc, const char* format, va_list ap,
   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
index 64377279b35672c1b16d3ba80392c7b125891599..fc32f481622534a93a98fc69278d5713d3db7d82 100644 (file)
@@ -23,23 +23,9 @@ along with GCC; see the file COPYING3.  If not see
 #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
@@ -156,20 +142,20 @@ extern void inform_n (location_t, unsigned HOST_WIDE_INT, const char *,
                      const char *, ...)
     ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
 extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
-extern bool emit_diagnostic (diagnostic_t,
+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,
index c53af2e8c1f68fd98c0cae4c7e787007e346a8eb..500f19cfb4f93883cb8d282acb59ee8bbb50378b 100644 (file)
@@ -53,7 +53,7 @@ verbatim (const char *gmsgid, ...)
    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, ...)
@@ -71,7 +71,7 @@ emit_diagnostic (diagnostic_t kind,
 /* 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, ...)
@@ -88,7 +88,7 @@ emit_diagnostic (diagnostic_t kind,
 /* 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)
@@ -101,7 +101,7 @@ emit_diagnostic_valist (diagnostic_t kind,
 /* 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,
@@ -120,7 +120,8 @@ inform (location_t location, const char *gmsgid, ...)
   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);
 }
 
@@ -133,7 +134,8 @@ inform (rich_location *richloc, const char *gmsgid, ...)
   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);
 }
 
@@ -149,7 +151,7 @@ inform_n (location_t location, unsigned HOST_WIDE_INT n,
   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);
 }
 
@@ -164,7 +166,8 @@ warning (diagnostics::option_id option_id, const char *gmsgid, ...)
   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;
 }
@@ -183,7 +186,8 @@ warning_at (location_t location,
   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;
 }
@@ -201,7 +205,8 @@ warning_at (rich_location *richloc,
   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;
 }
@@ -220,7 +225,8 @@ warning_meta (rich_location *richloc,
   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;
 }
@@ -240,7 +246,7 @@ warning_n (rich_location *richloc,
   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;
 }
@@ -261,7 +267,7 @@ warning_n (location_t location,
   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;
 }
@@ -289,7 +295,8 @@ pedwarn (location_t location,
   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;
 }
@@ -307,7 +314,8 @@ pedwarn (rich_location *richloc,
   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;
 }
@@ -327,7 +335,7 @@ permerror (location_t location, const char *gmsgid, ...)
   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;
 }
@@ -343,7 +351,7 @@ permerror (rich_location *richloc, const char *gmsgid, ...)
   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;
 }
@@ -362,7 +370,8 @@ permerror_opt (location_t location,
   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;
 }
@@ -380,7 +389,8 @@ permerror_opt (rich_location *richloc,
   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;
 }
@@ -394,7 +404,8 @@ error (const char *gmsgid, ...)
   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);
 }
 
@@ -410,7 +421,7 @@ error_n (location_t location, unsigned HOST_WIDE_INT n,
   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);
 }
 
@@ -422,7 +433,8 @@ error_at (location_t loc, const char *gmsgid, ...)
   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);
 }
 
@@ -436,7 +448,8 @@ error_at (rich_location *richloc, const char *gmsgid, ...)
   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);
 }
 
@@ -451,7 +464,8 @@ error_meta (rich_location *richloc, const diagnostics::metadata &metadata,
   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);
 }
 
@@ -465,7 +479,8 @@ sorry (const char *gmsgid, ...)
   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);
 }
 
@@ -477,7 +492,8 @@ sorry_at (location_t loc, const char *gmsgid, ...)
   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);
 }
 
@@ -499,7 +515,8 @@ fatal_error (location_t loc, const char *gmsgid, ...)
   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 ();
@@ -514,7 +531,8 @@ internal_error (const char *gmsgid, ...)
   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 ();
@@ -530,7 +548,8 @@ internal_error_no_backtrace (const char *gmsgid, ...)
   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 ();
index 86dffdd1e32098d8dc6cdda021a64ea9d8370920..5e2cb0e4d67ab7e7bbebac5fe9ce0be499368d17 100644 (file)
@@ -389,9 +389,9 @@ diagnostics::context::execution_failed_p () const
 {
   /* 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
@@ -580,7 +580,7 @@ diagnostics::context::initialize_fixits_change_set ()
 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;
@@ -598,15 +598,32 @@ diagnostic_set_info_translated (diagnostic_info *diagnostic, const char *msg,
 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
 };
@@ -615,11 +632,13 @@ static const char *const diagnostic_kind_color[] = {
    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).  */
@@ -709,21 +728,6 @@ location_print_policy (const diagnostics::text_sink &text_output)
 {
 }
 
-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.  */
 
@@ -827,9 +831,9 @@ diagnostics::context::check_max_errors (bool flush)
   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)
     {
@@ -846,18 +850,18 @@ diagnostics::context::check_max_errors (bool flush)
    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)
@@ -868,8 +872,8 @@ diagnostics::context::action_after_output (diagnostic_t diag_kind)
        }
       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.
@@ -882,7 +886,7 @@ diagnostics::context::action_after_output (diagnostic_t diag_kind)
          }
 
        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)
@@ -907,7 +911,7 @@ diagnostics::context::action_after_output (diagnostic_t diag_kind)
        exit (ICE_EXIT_CODE);
       }
 
-    case DK_FATAL:
+    case kind::fatal:
       if (m_abort_on_error)
        real_abort ();
       fnotice (stderr, "compilation terminated.\n");
@@ -1127,26 +1131,26 @@ diagnostics::context::diagnostic_enabled (diagnostic_info *diagnostic)
     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;
@@ -1166,7 +1170,7 @@ diagnostics::context::warning_enabled_at (location_t loc,
   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);
 }
 
@@ -1174,7 +1178,7 @@ diagnostics::context::warning_enabled_at (location_t loc,
 
 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,
@@ -1197,7 +1201,7 @@ emit_diagnostic_with_group (diagnostic_t kind,
 
 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,
@@ -1222,7 +1226,7 @@ emit_diagnostic_with_group_va (diagnostic_t kind,
 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
@@ -1231,8 +1235,8 @@ diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
 
   /* 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 ();
@@ -1242,15 +1246,15 @@ diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
   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
@@ -1258,8 +1262,8 @@ diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
      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;
 
@@ -1272,7 +1276,7 @@ diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
       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))
@@ -1280,11 +1284,11 @@ diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
        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)
@@ -1292,7 +1296,8 @@ diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
       /* 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
@@ -1304,14 +1309,14 @@ diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
 
   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
@@ -1329,15 +1334,15 @@ diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
   /* 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?  */
@@ -1395,8 +1400,8 @@ diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
       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;
 
@@ -1495,19 +1500,19 @@ diagnostics::context::diagnostic_impl (rich_location *richloc,
                                     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;
@@ -1523,7 +1528,7 @@ diagnostics::context::diagnostic_n_impl (rich_location *richloc,
                                       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;
@@ -1538,7 +1543,7 @@ diagnostics::context::diagnostic_n_impl (rich_location *richloc,
 
   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);
@@ -1573,7 +1578,7 @@ diagnostics::context::error_recursion ()
 
   /* 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.  */
@@ -1599,7 +1604,7 @@ fancy_abort (const char *file, int line, const char *function)
   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);
 
@@ -1754,12 +1759,12 @@ diagnostics::counters::dump (FILE *out, int indent) const
 {
   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;
       }
@@ -1770,7 +1775,7 @@ diagnostics::counters::dump (FILE *out, int indent) const
 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 ();
 }
index 69bc798c9b182053619c69bef94b83e86ac40673..a0ba115370831f54cda50e684dfd0b3cb2ab3b62 100644 (file)
@@ -167,13 +167,13 @@ extern diagnostics::context *global_dc;
 
 /* 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)                          \
@@ -220,7 +220,7 @@ inline void
 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)
 {
@@ -234,7 +234,7 @@ inline void
 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)
@@ -269,10 +269,10 @@ diagnostic_initialize_input_context (diagnostics::context *context,
 }
 
 /* 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);
@@ -310,10 +310,10 @@ diagnostic_report_diagnostic (diagnostics::context *context,
 
 #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
 
@@ -327,7 +327,7 @@ void default_start_span_fn (const diagnostics::location_print_policy &,
                            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);
@@ -379,8 +379,6 @@ diagnostic_same_line (const diagnostics::context *context,
              > 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;
@@ -402,8 +400,6 @@ option_unspecified_p (diagnostics::option_id opt_id)
 
 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);
index 53afc90f02b727ee22cbf1379abb0a8dd8dbfd28..29f039febad259474c863af5304bcee0ad0eb5a2 100644 (file)
@@ -89,14 +89,14 @@ void
 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);
 }
 
index 1e65b4e37b6f2875cd6d25d7697fe98b2cf3a1b9..c3ac070ba00b8f60dc1b70d6249520e19379ce3a 100644 (file)
@@ -66,7 +66,7 @@ class buffer
   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);
   }
index 78663cdf1e56dd9142e4485fb6bada57c38b60ef..c985d51f4706f8dc593b9a9c3d2d1c7ea5d56d99 100644 (file)
@@ -46,7 +46,7 @@ using start_span_fn = void (*) (const location_print_policy &,
 
 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.  */
@@ -67,8 +67,8 @@ public:
      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.
@@ -205,13 +205,13 @@ public:
   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;
 
@@ -269,12 +269,15 @@ struct counters
   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
@@ -370,13 +373,13 @@ public:
     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,
@@ -391,9 +394,9 @@ public:
   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,
@@ -413,12 +416,12 @@ public:
 
   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);
@@ -498,11 +501,11 @@ public:
 
   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);
   }
@@ -516,8 +519,8 @@ public:
   }
 
   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;
@@ -544,11 +547,11 @@ public:
 
   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
   {
@@ -595,7 +598,7 @@ public:
 
   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)
   {
@@ -649,7 +652,7 @@ private:
   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.  */
index 621f95a856a629061c49ef69a19159bd423d0300..052fef52f1eb1cd35b7be23235e7688644488b99 100644 (file)
@@ -26,7 +26,7 @@ class metadata;
 
 /* 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
 {
@@ -53,7 +53,7 @@ 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;
 
index f62a3ca4cf44668901aa5603ed98e763ed3e10f8..a0202546a59f92d8b1de715c797d981a0e32950e 100644 (file)
@@ -120,7 +120,7 @@ public:
   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 &);
@@ -161,7 +161,7 @@ private:
 
   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>
@@ -496,10 +496,10 @@ html_builder::add_stylesheet (std::string url)
 
 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
@@ -722,23 +722,23 @@ private:
 
 /* 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:
@@ -747,23 +747,23 @@ get_pf_class_for_alert_div (diagnostic_t diag_kind)
 }
 
 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:
@@ -946,7 +946,7 @@ private:
 
 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++;
@@ -1004,7 +1004,7 @@ html_builder::make_element_for_diagnostic (const diagnostic_info &diagnostic,
   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 (" ");
   }
@@ -1360,7 +1360,7 @@ public:
   }
   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);
   }
@@ -1463,7 +1463,7 @@ open_html_output_file (context &dc,
     {
       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 ();
     }
@@ -1476,7 +1476,7 @@ open_html_output_file (context &dc,
     {
       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 ();
@@ -1620,7 +1620,7 @@ test_simple_log ()
   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 ();
 
similarity index 53%
rename from gcc/diagnostic.def
rename to gcc/diagnostics/kinds.def
index ab2185c2cd07de1a183c91b6c16d70f45c864c82..2a0a0a6c7095d8cb20a8f4ae26fc5aac289cb711 100644 (file)
@@ -16,40 +16,40 @@ 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/>.  */
 
-/* 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")
diff --git a/gcc/diagnostics/kinds.h b/gcc/diagnostics/kinds.h
new file mode 100644 (file)
index 0000000..7b4a168
--- /dev/null
@@ -0,0 +1,45 @@
+/* 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 */
index 216ad744a3b720327bc85445973024ba6c98d728..4934651c322953562a0dd7731ba52569300e5c3f 100644 (file)
@@ -139,8 +139,8 @@ public:
     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;
   }
@@ -175,7 +175,7 @@ test_emission (pretty_printer *event_pp)
 
     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);
@@ -191,7 +191,7 @@ test_emission (pretty_printer *event_pp)
     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 ());
index d3f0985d4647b42ffa52a8446e6e54a59d40bbda..98316b46f1fe646430be7b6b2f32b4cd81e00f74 100644 (file)
@@ -30,9 +30,9 @@ void
 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;
 }
@@ -111,27 +111,27 @@ option_classifier::pop (location_t where)
   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];
 
@@ -141,11 +141,11 @@ option_classifier::classify_diagnostic (const context *dc,
     {
       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;
        }
 
@@ -172,15 +172,15 @@ option_classifier::classify_diagnostic (const context *dc,
      #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
@@ -197,7 +197,7 @@ update_effective_level_from_pragmas (diagnostic_info *diagnostic) const
          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;
@@ -208,15 +208,15 @@ update_effective_level_from_pragmas (diagnostic_info *diagnostic) const
          /* 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
index 045d18925d07dfc3deb253a1f1414b1871647b43..3b16c740b7eaab386a6ddaedd7c39c3024b0f4d6 100644 (file)
@@ -44,22 +44,22 @@ public:
 
   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 *);
@@ -73,12 +73,12 @@ private:
   {
     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;
@@ -86,10 +86,10 @@ private:
   /* 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
index 111e5aba6bac24fd77fd88eb0c136a184e0b42a4..c84d237de49955226bb826b85e68337c6d1eb349 100644 (file)
@@ -103,7 +103,7 @@ public:
   {
     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 ();
   }
 
index 0349f3d943d6e5e4625f0312eb8f8cb72ecffc12..c132d67350427ab744633fd792704375c118a257 100644 (file)
@@ -638,7 +638,7 @@ struct event_range
 
     /* 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.  */
@@ -702,7 +702,7 @@ struct event_range
     /* 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
index 617cc51970b8b26e0f4395063f7684730798be8d..451ed5990eee66e3ecbd9794e2989d8ccf8d2766 100644 (file)
@@ -452,7 +452,7 @@ public:
 
   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);
@@ -775,7 +775,7 @@ public:
   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 ();
@@ -854,7 +854,7 @@ private:
 
   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,
@@ -918,7 +918,7 @@ private:
   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;
@@ -1307,7 +1307,7 @@ sarif_location_manager::process_worklist_item (sarif_builder &builder,
 
 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;
@@ -1840,12 +1840,12 @@ sarif_builder::set_main_input_filename (const char *name)
 
 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,
@@ -1949,16 +1949,16 @@ sarif_builder::flush_to_file (FILE *outf)
    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;
@@ -1970,10 +1970,10 @@ maybe_get_sarif_level (diagnostic_t diag_kind)
    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] == ':');
@@ -1987,7 +1987,7 @@ make_rule_id_for_diagnostic_kind (diagnostic_t diag_kind)
 
 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);
@@ -2106,7 +2106,7 @@ sarif_builder::make_result_object (const diagnostic_info &diagnostic,
 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> ();
@@ -2281,7 +2281,7 @@ sarif_builder::make_location_object (sarif_location_manager *loc_mgr,
       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
@@ -3915,7 +3915,7 @@ public:
   }
   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);
   }
@@ -4189,7 +4189,7 @@ output_file::try_to_open (context &dc,
     {
       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 ();
     }
@@ -4202,7 +4202,7 @@ output_file::try_to_open (context &dc,
     {
       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 ();
@@ -4583,7 +4583,7 @@ test_simple_log (const sarif_generation_options &sarif_gen_opts)
   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 ();
 
@@ -4720,7 +4720,7 @@ test_simple_log_2 (const sarif_generation_options &sarif_gen_opts,
                     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");
 
@@ -4848,7 +4848,7 @@ test_message_with_embedded_link (const sarif_generation_options &sarif_gen_opts)
   {
     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 ();
@@ -4871,7 +4871,7 @@ test_message_with_embedded_link (const sarif_generation_options &sarif_gen_opts)
 #  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
@@ -4905,7 +4905,7 @@ test_message_with_embedded_link (const sarif_generation_options &sarif_gen_opts)
     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 ();
 
@@ -4926,7 +4926,7 @@ test_message_with_braces (const sarif_generation_options &sarif_gen_opts)
   {
     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 ();
@@ -4948,21 +4948,21 @@ test_buffering (const sarif_generation_options &sarif_gen_opts)
 
   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);
@@ -4975,11 +4975,11 @@ test_buffering (const sarif_generation_options &sarif_gen_opts)
   /* 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 ());
@@ -4988,11 +4988,11 @@ test_buffering (const sarif_generation_options &sarif_gen_opts)
   /* 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 ());
@@ -5001,9 +5001,9 @@ test_buffering (const sarif_generation_options &sarif_gen_opts)
   /* 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);
@@ -5016,9 +5016,9 @@ test_buffering (const sarif_generation_options &sarif_gen_opts)
   /* 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 ());
index 880c169fa861136177ae1ca41ebe3ad7a28e679b..4f215c222e2566d522c25248c0ca6de83f577d47 100644 (file)
@@ -68,7 +68,7 @@ start_span_cb (const location_print_policy &loc_policy,
 }
 
 bool
-test_context::report (diagnostic_t kind,
+test_context::report (enum kind kind,
                      rich_location &richloc,
                      const metadata *metadata_,
                      option_id opt_id,
@@ -92,7 +92,7 @@ test_context::test_show_locus (rich_location &richloc)
   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);
 }
 
index e1a96d5ab986cefd98e2a334964a174605d7099b..faa81bf5456a9460c2b141dbe9e5b68495bb872d 100644 (file)
@@ -48,7 +48,7 @@ class test_context : public context
      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,
index e8b54180806340cc83007bd8470d2d6f91b0edf0..04de99a06df1b6db8429775127cbeae95e507a7c 100644 (file)
@@ -59,7 +59,7 @@ public:
   /* 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 &);
 
index 84289942b6909d40f6660344f76529af12a14e79..8555ae41fb771385ce4427e6c5883f43ceedae1f 100644 (file)
@@ -96,7 +96,7 @@ class colorizer
  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)
@@ -116,7 +116,7 @@ class colorizer
        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);
@@ -141,7 +141,7 @@ class colorizer
 
   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;
@@ -947,7 +947,7 @@ private:
 
 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),
@@ -1025,7 +1025,7 @@ colorizer::begin_state (int state)
       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:
@@ -3851,7 +3851,7 @@ namespace diagnostics {
 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)
 {
@@ -3884,7 +3884,7 @@ context::maybe_show_locus (const rich_location &richloc,
 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)
@@ -3945,14 +3945,14 @@ source_print_policy::source_print_policy (const context &dc,
 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);
 }
 
@@ -3962,14 +3962,14 @@ source_print_policy::print (pretty_printer &pp,
 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);
 }
@@ -4043,7 +4043,7 @@ using temp_source_file = ::selftest::temp_source_file;
 
 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;
@@ -4064,7 +4064,7 @@ make_element_for_locus (const rich_location &rich_loc,
 
 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);
@@ -4292,7 +4292,7 @@ test_layout_x_offset_display_utf8 (const line_table_case &case_)
                                                        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);
@@ -4322,7 +4322,7 @@ test_layout_x_offset_display_utf8 (const line_table_case &case_)
                                                        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);
@@ -4406,7 +4406,7 @@ test_layout_x_offset_display_tab (const line_table_case &case_)
       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);
@@ -4434,7 +4434,7 @@ test_layout_x_offset_display_tab (const line_table_case &case_)
       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);
@@ -4520,7 +4520,7 @@ test_one_liner_caret_and_range ()
 
   {
     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"
@@ -4533,7 +4533,7 @@ test_one_liner_caret_and_range ()
   {
     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"
@@ -4964,7 +4964,8 @@ test_one_liner_labels ()
     {
       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"
index 6fdbf22308f02f121adbab017d1388cd12cee79d..bcf91cf0f4ff2293601bca5fb42fc737406cdc96 100644 (file)
@@ -132,7 +132,7 @@ text_sink_buffer::flush ()
 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.  */
@@ -201,7 +201,7 @@ text_sink::make_per_sink_buffer ()
 
 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 ();
 
@@ -291,13 +291,13 @@ after_diagnostic (const diagnostic_info &diagnostic)
 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));
@@ -310,7 +310,7 @@ text_sink::build_prefix (const diagnostic_info &diagnostic) const
 
       /* 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,
@@ -416,7 +416,7 @@ text_sink::append_note (location_t location,
   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);
@@ -431,7 +431,7 @@ text_sink::append_note (location_t location,
   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);
 }
 
@@ -478,7 +478,7 @@ text_sink::print_any_cwe (const diagnostic_info &diagnostic)
       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 ())
        {
@@ -516,8 +516,7 @@ text_sink::print_any_rules (const diagnostic_info &diagnostic)
          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 ())
@@ -544,7 +543,7 @@ text_sink::print_any_rules (const diagnostic_info &diagnostic)
 
 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,
@@ -555,7 +554,7 @@ text_sink::print_option_information (const diagnostic_info &diagnostic,
       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);
@@ -709,7 +708,7 @@ default_text_starter (text_sink &text_output,
 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);
index fdbbbb41b27c4ef6d0a0893349eb4e12c0fddfeb..de7b71d6a0cacd900cfada404a6d84701a979c2f 100644 (file)
@@ -60,7 +60,7 @@ public:
   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;
@@ -130,7 +130,7 @@ protected:
   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);
 
index 3e540072a5de6f2b74b0d7abb86660c1b955cf2a..01113589fe7b423d0060979d24740fabb235455e 100644 (file)
@@ -1089,7 +1089,7 @@ cb_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
                   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;
 
@@ -1099,22 +1099,22 @@ cb_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
       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 ();
index a9e99b4c3da0df6317cd4c9fedcda8c13467a70d..8d913aa89ef6495911861c9a6f66133806a9defe 100644 (file)
@@ -272,7 +272,7 @@ gfc_warning (int opt, const char *gmsgid, va_list ap)
     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);
 
@@ -441,7 +441,7 @@ gfc_format_decoder (pretty_printer *pp, text_info *text, const char *spec,
        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)));
@@ -475,15 +475,16 @@ gfc_diagnostic_build_kind_prefix (diagnostics::context *context,
 #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);
@@ -636,7 +637,7 @@ gfc_diagnostic_start_span (const diagnostics::location_print_policy &loc_policy,
 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);
@@ -655,7 +656,8 @@ gfc_warning_now_at (location_t loc, int opt, const char *gmsgid, ...)
   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);
@@ -674,7 +676,7 @@ gfc_warning_now (int opt, const char *gmsgid, ...)
 
   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);
@@ -693,7 +695,7 @@ gfc_warning_internal (int opt, const char *gmsgid, ...)
 
   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);
@@ -712,7 +714,8 @@ gfc_error_now (const char *gmsgid, ...)
   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);
 }
@@ -728,7 +731,8 @@ gfc_fatal_error (const char *gmsgid, ...)
   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);
 
@@ -786,7 +790,8 @@ gfc_error_opt (int opt, const char *gmsgid, va_list ap)
   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)
@@ -831,7 +836,8 @@ gfc_internal_error (const char *gmsgid, ...)
     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);
 
index d3c9066630b72ff7362eecbe1661296a8e3c8365..821a8c88bbbb755b8490267065b67fb4f2a8adae 100644 (file)
@@ -406,7 +406,8 @@ gfc_post_options (const char **pfilename)
       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
     {
index 0899018fdb6d4e2504584a228066f2b5a05823f9..bfa588ee5f0432a7e212c6cfc36ac2ad122adeaf 100644 (file)
@@ -4207,7 +4207,8 @@ driver_handle_option (struct gcc_options *opts,
 
   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);
 
index 7fe65a1f3afa6ad3699e7d67a183691c3ce17d4f..5b56b730452308fb857df37f56088b71d1de5c06 100644 (file)
@@ -1016,7 +1016,7 @@ public:
   }
 
   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 ());
 
@@ -1056,7 +1056,7 @@ jit_begin_diagnostic (diagnostics::text_sink &,
 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 ());
index 0ac2cef1f9ac45ef46512ff27572f79811384a1f..9ae4d210e35facde1924fd3305865c08ae80ffa4 100644 (file)
@@ -1334,21 +1334,21 @@ private:
   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;
     }
 }
 
@@ -1616,7 +1616,8 @@ diagnostic_manager::emit_va (diagnostic &diag, const char *msgid, va_list *args)
     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;
index ad204a778fd2c082e2b4bff67470bd1a5db50c4d..cb293f21099315d200bc9f6434cd027067ca8342 100644 (file)
@@ -2279,8 +2279,8 @@ public:
     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;
   }
index feb62b3ed4d84af29fac7679bf22ce36ef4c7c8c..0f0bd6541f1dd4277d3059b69cc82ae0e694061c 100644 (file)
@@ -193,7 +193,8 @@ m2linemap_ErrorAtf_1 (location_t location, const char *message, ...)
   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);
 }
@@ -214,7 +215,8 @@ m2linemap_WarningAtf_1 (location_t location, const char *message, ...)
   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);
 }
@@ -235,7 +237,8 @@ m2linemap_NoteAtf_1 (location_t location, const char *message, ...)
   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);
 }
index cd125823a062e41f7b809cc10fd71b40a178f85e..00df71d57f6d72d6f85df57c249f4f9053606879 100644 (file)
@@ -283,7 +283,8 @@ rtegraph_lookup (gimple *g, tree fndecl, bool is_call)
 /* 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;
@@ -338,7 +339,7 @@ access_string (tree t, const char **value)
    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)
     {
@@ -393,15 +394,16 @@ const char *rtenode::create_message (const char *with_name, const char *without_
   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)
 {
@@ -409,15 +411,16 @@ 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.  */
index ebc23b4b00be55dab62c48ddd4bad6ef625d25db..91cad49b9bd77e3fd67a0e64728d33a70e3bbff3 100644 (file)
@@ -1282,9 +1282,9 @@ keep:
 
 /* 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
@@ -1645,7 +1645,8 @@ read_cmdline_option (struct gcc_options *opts,
 
   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);
 }
@@ -1668,8 +1669,10 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
   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);
@@ -1954,7 +1957,9 @@ control_warning_option (unsigned int opt_index, int kind, const char *arg,
   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.  */
index d6382892a6b6959d0044581288cf3f089baa4d5b..4fa4ea8a6f5a602a72deffe33d1218b84f9f2b82 100644 (file)
@@ -50,9 +50,10 @@ public:
   }
 
   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;
index cdf44aed4bb31b420b49af9222e10bed7c00780b..ec999be391008badbb4dc8b100f8eb5593efa194 100644 (file)
@@ -371,7 +371,8 @@ target_handle_option (struct gcc_options *opts,
                      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);
 }
 
@@ -535,14 +536,18 @@ maybe_default_option (struct gcc_options *opts,
   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);
 }
 
@@ -3317,7 +3322,9 @@ common_handle_option (struct gcc_options *opts,
 
     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);
@@ -3717,7 +3724,9 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
              "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)
@@ -3737,14 +3746,15 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
 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,
@@ -3754,8 +3764,9 @@ make_option_name (diagnostics::option_id option_id,
        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
index 06d060c06db220a1a04e25ac261de923c2dc7f30..04a449ccf31803567f5c2898608ef5226ce53bee 100644 (file)
@@ -28,7 +28,7 @@ along with GCC; see the file COPYING3.  If not see
 
 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
@@ -64,7 +64,7 @@ location_for_asm (const rtx_insn *insn)
    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));
@@ -80,7 +80,7 @@ error_for_asm (const rtx_insn *insn, const char *gmsgid, ...)
   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);
 }
 
@@ -90,7 +90,7 @@ warning_for_asm (const rtx_insn *insn, const char *gmsgid, ...)
   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);
 }
 
index 6cba04b3c27703ca07daa7452a285a813cba2e68..2302ffb55f2f2ed4a29751423d604c4158e07474 100644 (file)
@@ -3848,16 +3848,18 @@ strip_top_quals (tree t)
 /* 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)
@@ -5131,7 +5133,7 @@ complete_type_or_maybe_complain (tree type, tree value, tsubst_flags_t complain)
   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;
     }
index bb99684b2bf8c0fa2077bdbaf223a28b1ea6dfc0..3630b0e6bdeb5ac1de55a882bdf7bd27f8fbd654 100644 (file)
@@ -3137,7 +3137,7 @@ extern bool reject_gcc_builtin (const_tree, location_t = UNKNOWN_LOCATION);
 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);
 
@@ -3430,7 +3430,7 @@ null_node_p (const_tree expr)
 
 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);
@@ -3439,7 +3439,7 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
 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
index 6f6f2bf0bfd9ca514a1e9d04fda2f4305f627625..5524e18ab5f7fbea6fdf059e9514461a09edd34d 100644 (file)
@@ -130,7 +130,7 @@ ResolveExpr::visit (AST::IdentifierExpr &expr)
         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 ());
     }
index 9e71531a6addf43f32e562644ba95def8522fd9e..2a0cd3bbd3cacf426365723af7fbeca49644c06a 100644 (file)
@@ -24,9 +24,9 @@ namespace Resolver {
 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);
index 6759e67c739ca416de157aaf3e96524300d27cea..f36e5582e5c1297d6c57a7170a7ad307a8427c0a 100644 (file)
@@ -57,7 +57,7 @@ namespace Resolver {
 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
index fe9dea8fa62b62f87574cf975a8675d3de61ed8a..a15e17ff9a7f92b6861f829c7085a32d4601c980 100644 (file)
@@ -376,7 +376,7 @@ Late::visit (AST::IdentifierExpr &expr)
   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 ());
     }
index 59affc60a96500ddd412ddfa6a339be418055b01..9bbc76bec8c1c340a92c3d6060dc9e0e2da7ccaa 100644 (file)
@@ -218,11 +218,11 @@ format_string_diagnostic_t::emit_warning_n_va (diagnostics::option_id option_id,
 
       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);
 
index 0342ccc2c4ba71e6315b827fabbe47b411742973..5c277d71e18a74e7139cef70e9fafd68c120c034 100644 (file)
@@ -132,7 +132,7 @@ static bool force_show_locus_color = false;
 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);
index bad14617a4848524bc0b8070ca489b2741062d73..ea37921acacb6a249de402564b49966b0c08f748 100644 (file)
@@ -49,7 +49,8 @@ test_richloc (rich_location *richloc)
   /* 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 ());
index d45a33d168feeb7822664c43a0fa9a40fbd3a678..bd8019a701f49d1552d84df41beeb356c3d06d87 100644 (file)
@@ -44,7 +44,7 @@ static diagnostics::text_finalizer_fn original_text_finalizer = NULL;
 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);
@@ -58,7 +58,7 @@ verify_unpacked_ranges  (diagnostics::text_sink &text_output,
 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);
index 312c4b8659a4962429defdbfc80dd62f54ef6af9..859a943a3b10edaed3fccd42e9b6c55e8b786091 100644 (file)
@@ -1338,8 +1338,8 @@ proc dg-missed { args } {
 }
 
 # 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
index 9d4f3581e922089d6db98a6006fd313438588fa4..e0eac813ce72d3cfa87beb5bd70061c7d819650c 100644 (file)
@@ -1748,11 +1748,13 @@ process_options ()
       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.  */
index 9973836068b0f145b46463ab2a472cc9c5332955..8ca4c75b6ccf2f66f0d7a9d10a8cff578a27d0f6 100644 (file)
@@ -622,8 +622,8 @@ struct cpp_reader
      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