aboutsummaryrefslogtreecommitdiff
path: root/gcc/diagnostic-global-context.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/diagnostic-global-context.cc')
-rw-r--r--gcc/diagnostic-global-context.cc121
1 files changed, 70 insertions, 51 deletions
diff --git a/gcc/diagnostic-global-context.cc b/gcc/diagnostic-global-context.cc
index 1165915..500f19c 100644
--- a/gcc/diagnostic-global-context.cc
+++ b/gcc/diagnostic-global-context.cc
@@ -27,11 +27,11 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "intl.h"
#include "diagnostic.h"
-#include "diagnostic-format.h"
+#include "diagnostics/sink.h"
-/* A diagnostic_context surrogate for stderr. */
-static diagnostic_context global_diagnostic_context;
-diagnostic_context *global_dc = &global_diagnostic_context;
+/* A diagnostics::context surrogate for stderr. */
+static diagnostics::context global_diagnostic_context;
+diagnostics::context *global_dc = &global_diagnostic_context;
/* Standard error reporting routines in increasing order of severity. */
@@ -49,13 +49,13 @@ verbatim (const char *gmsgid, ...)
va_end (ap);
}
-/* Wrapper around diagnostic_context::diagnostic_impl
+/* Wrapper around diagnostics::context::diagnostic_impl
implying global_dc and taking a variable argument list. */
bool
-emit_diagnostic (diagnostic_t kind,
+emit_diagnostic (enum diagnostics::kind kind,
location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
auto_diagnostic_group d;
@@ -71,9 +71,9 @@ 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,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
auto_diagnostic_group d;
@@ -88,9 +88,9 @@ 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,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, va_list *ap)
{
rich_location richloc (line_table, location);
@@ -101,10 +101,10 @@ 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 diagnostic_metadata *metadata,
- diagnostic_option_id option_id,
+ const diagnostics::metadata *metadata,
+ diagnostics::option_id option_id,
const char *gmsgid, va_list *ap)
{
return global_dc->diagnostic_impl (richloc, metadata, 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);
}
@@ -157,14 +159,15 @@ inform_n (location_t location, unsigned HOST_WIDE_INT n,
to the relevant language specification but is likely to be buggy anyway.
Returns true if the warning was printed, false if it was inhibited. */
bool
-warning (diagnostic_option_id option_id, const char *gmsgid, ...)
+warning (diagnostics::option_id option_id, const char *gmsgid, ...)
{
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
rich_location richloc (line_table, input_location);
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id,
- gmsgid, &ap, DK_WARNING);
+ gmsgid, &ap,
+ diagnostics::kind::warning);
va_end (ap);
return ret;
}
@@ -175,7 +178,7 @@ warning (diagnostic_option_id option_id, const char *gmsgid, ...)
bool
warning_at (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
auto_diagnostic_group d;
@@ -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;
}
@@ -192,7 +196,7 @@ warning_at (location_t location,
bool
warning_at (rich_location *richloc,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
gcc_assert (richloc);
@@ -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;
}
@@ -210,8 +215,8 @@ warning_at (rich_location *richloc,
bool
warning_meta (rich_location *richloc,
- const diagnostic_metadata &metadata,
- diagnostic_option_id option_id,
+ const diagnostics::metadata &metadata,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
gcc_assert (richloc);
@@ -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;
}
@@ -229,7 +235,7 @@ warning_meta (rich_location *richloc,
bool
warning_n (rich_location *richloc,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
unsigned HOST_WIDE_INT n,
const char *singular_gmsgid, const char *plural_gmsgid, ...)
{
@@ -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;
}
@@ -251,7 +257,7 @@ warning_n (rich_location *richloc,
bool
warning_n (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
unsigned HOST_WIDE_INT n,
const char *singular_gmsgid, const char *plural_gmsgid, ...)
{
@@ -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;
}
@@ -281,7 +287,7 @@ warning_n (location_t location,
bool
pedwarn (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
auto_diagnostic_group d;
@@ -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;
}
@@ -298,7 +305,7 @@ pedwarn (location_t location,
bool
pedwarn (rich_location *richloc,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
gcc_assert (richloc);
@@ -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;
}
@@ -354,7 +362,7 @@ permerror (rich_location *richloc, const char *gmsgid, ...)
bool
permerror_opt (location_t location,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
auto_diagnostic_group d;
@@ -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;
}
@@ -371,7 +380,7 @@ permerror_opt (location_t location,
bool
permerror_opt (rich_location *richloc,
- diagnostic_option_id option_id,
+ diagnostics::option_id option_id,
const char *gmsgid, ...)
{
gcc_assert (richloc);
@@ -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,14 +448,15 @@ 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);
}
/* Same as above, but with metadata. */
void
-error_meta (rich_location *richloc, const diagnostic_metadata &metadata,
+error_meta (rich_location *richloc, const diagnostics::metadata &metadata,
const char *gmsgid, ...)
{
gcc_assert (richloc);
@@ -451,7 +464,8 @@ error_meta (rich_location *richloc, const diagnostic_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 ();