diff options
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r-- | gcc/diagnostic.c | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index a98bf4a..9db4b46 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -50,12 +50,9 @@ along with GCC; see the file COPYING3. If not see /* Prototypes. */ static bool diagnostic_impl (rich_location *, int, const char *, va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(3,0); -static bool diagnostic_n_impl (location_t, int, int, const char *, +static bool diagnostic_n_impl (rich_location *, int, int, const char *, const char *, va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0); -static bool diagnostic_n_impl_richloc (rich_location *, int, int, const char *, - const char *, va_list *, - diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0); static void error_recursion (diagnostic_context *) ATTRIBUTE_NORETURN; static void real_abort (void) ATTRIBUTE_NORETURN; @@ -1074,10 +1071,9 @@ diagnostic_append_note (diagnostic_context *context, va_end (ap); } -/* Implement emit_diagnostic, inform, inform_at_rich_loc, warning, warning_at, - warning_at_rich_loc, pedwarn, permerror, permerror_at_rich_loc, error, - error_at, error_at_rich_loc, sorry, fatal_error, internal_error, and - internal_error_no_backtrace, as documented and defined below. */ +/* Implement emit_diagnostic, inform, warning, warning_at, pedwarn, + permerror, error, error_at, error_at, sorry, fatal_error, internal_error, + and internal_error_no_backtrace, as documented and defined below. */ static bool diagnostic_impl (rich_location *richloc, int opt, const char *gmsgid, @@ -1099,12 +1095,13 @@ diagnostic_impl (rich_location *richloc, int opt, return diagnostic_report_diagnostic (global_dc, &diagnostic); } -/* Same as diagonostic_n_impl taking rich_location instead of location_t. */ +/* Implement inform_n, warning_n, and error_n, as documented and + defined below. */ static bool -diagnostic_n_impl_richloc (rich_location *richloc, int opt, int n, - const char *singular_gmsgid, - const char *plural_gmsgid, - va_list *ap, diagnostic_t kind) +diagnostic_n_impl (rich_location *richloc, int opt, int n, + const char *singular_gmsgid, + const char *plural_gmsgid, + va_list *ap, diagnostic_t kind) { diagnostic_info diagnostic; diagnostic_set_info_translated (&diagnostic, @@ -1113,19 +1110,6 @@ diagnostic_n_impl_richloc (rich_location *richloc, int opt, int n, if (kind == DK_WARNING) diagnostic.option_index = opt; return diagnostic_report_diagnostic (global_dc, &diagnostic); -} - -/* Implement inform_n, warning_n, and error_n, as documented and - defined below. */ -static bool -diagnostic_n_impl (location_t location, int opt, int n, - const char *singular_gmsgid, - const char *plural_gmsgid, - va_list *ap, diagnostic_t kind) -{ - rich_location richloc (line_table, location); - return diagnostic_n_impl_richloc (&richloc, opt, n, - singular_gmsgid, plural_gmsgid, ap, kind); } /* Wrapper around diagnostic_impl taking a variable argument list. */ @@ -1164,10 +1148,12 @@ inform (location_t location, const char *gmsgid, ...) va_end (ap); } -/* Same as "inform", but at RICHLOC. */ +/* Same as "inform" above, but at RICHLOC. */ void -inform_at_rich_loc (rich_location *richloc, const char *gmsgid, ...) +inform (rich_location *richloc, const char *gmsgid, ...) { + gcc_assert (richloc); + va_list ap; va_start (ap, gmsgid); diagnostic_impl (richloc, -1, gmsgid, &ap, DK_NOTE); @@ -1182,7 +1168,8 @@ inform_n (location_t location, int n, const char *singular_gmsgid, { va_list ap; va_start (ap, plural_gmsgid); - diagnostic_n_impl (location, -1, n, singular_gmsgid, plural_gmsgid, + rich_location richloc (line_table, location); + diagnostic_n_impl (&richloc, -1, n, singular_gmsgid, plural_gmsgid, &ap, DK_NOTE); va_end (ap); } @@ -1216,11 +1203,13 @@ warning_at (location_t location, int opt, const char *gmsgid, ...) return ret; } -/* Same as warning at, but using RICHLOC. */ +/* Same as "warning at" above, but using RICHLOC. */ bool -warning_at_rich_loc (rich_location *richloc, int opt, const char *gmsgid, ...) +warning_at (rich_location *richloc, int opt, const char *gmsgid, ...) { + gcc_assert (richloc); + va_list ap; va_start (ap, gmsgid); bool ret = diagnostic_impl (richloc, opt, gmsgid, &ap, DK_WARNING); @@ -1228,17 +1217,19 @@ warning_at_rich_loc (rich_location *richloc, int opt, const char *gmsgid, ...) return ret; } -/* Same as warning_at_rich_loc but for plural variant. */ +/* Same as warning_n plural variant below, but using RICHLOC. */ bool -warning_at_rich_loc_n (rich_location *richloc, int opt, int n, - const char *singular_gmsgid, const char *plural_gmsgid, ...) +warning_n (rich_location *richloc, int opt, int n, + const char *singular_gmsgid, const char *plural_gmsgid, ...) { + gcc_assert (richloc); + va_list ap; va_start (ap, plural_gmsgid); - bool ret = diagnostic_n_impl_richloc (richloc, opt, n, - singular_gmsgid, plural_gmsgid, - &ap, DK_WARNING); + bool ret = diagnostic_n_impl (richloc, opt, n, + singular_gmsgid, plural_gmsgid, + &ap, DK_WARNING); va_end (ap); return ret; } @@ -1253,7 +1244,8 @@ warning_n (location_t location, int opt, int n, const char *singular_gmsgid, { va_list ap; va_start (ap, plural_gmsgid); - bool ret = diagnostic_n_impl (location, opt, n, + rich_location richloc (line_table, location); + bool ret = diagnostic_n_impl (&richloc, opt, n, singular_gmsgid, plural_gmsgid, &ap, DK_WARNING); va_end (ap); @@ -1284,11 +1276,13 @@ pedwarn (location_t location, int opt, const char *gmsgid, ...) return ret; } -/* Same as pedwarn, but using RICHLOC. */ +/* Same as pedwarn above, but using RICHLOC. */ bool -pedwarn_at_rich_loc (rich_location *richloc, int opt, const char *gmsgid, ...) +pedwarn (rich_location *richloc, int opt, const char *gmsgid, ...) { + gcc_assert (richloc); + va_list ap; va_start (ap, gmsgid); bool ret = diagnostic_impl (richloc, opt, gmsgid, &ap, DK_PEDWARN); @@ -1314,11 +1308,13 @@ permerror (location_t location, const char *gmsgid, ...) return ret; } -/* Same as "permerror", but at RICHLOC. */ +/* Same as "permerror" above, but at RICHLOC. */ bool -permerror_at_rich_loc (rich_location *richloc, const char *gmsgid, ...) +permerror (rich_location *richloc, const char *gmsgid, ...) { + gcc_assert (richloc); + va_list ap; va_start (ap, gmsgid); bool ret = diagnostic_impl (richloc, -1, gmsgid, &ap, DK_PERMERROR); @@ -1346,7 +1342,8 @@ error_n (location_t location, int n, const char *singular_gmsgid, { va_list ap; va_start (ap, plural_gmsgid); - diagnostic_n_impl (location, -1, n, singular_gmsgid, plural_gmsgid, + rich_location richloc (line_table, location); + diagnostic_n_impl (&richloc, -1, n, singular_gmsgid, plural_gmsgid, &ap, DK_ERROR); va_end (ap); } @@ -1365,8 +1362,10 @@ error_at (location_t loc, const char *gmsgid, ...) /* Same as above, but use RICH_LOC. */ void -error_at_rich_loc (rich_location *richloc, const char *gmsgid, ...) +error_at (rich_location *richloc, const char *gmsgid, ...) { + gcc_assert (richloc); + va_list ap; va_start (ap, gmsgid); diagnostic_impl (richloc, -1, gmsgid, &ap, DK_ERROR); |