GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "intl.h"
#include "diagnostic.h"
#include "diagnostic-format.h"
Functions | |
void | verbatim (const char *gmsgid,...) |
bool | emit_diagnostic (diagnostic_t kind, location_t location, diagnostic_option_id option_id, const char *gmsgid,...) |
bool | emit_diagnostic (diagnostic_t kind, rich_location *richloc, diagnostic_option_id option_id, const char *gmsgid,...) |
bool | emit_diagnostic_valist (diagnostic_t kind, location_t location, diagnostic_option_id option_id, const char *gmsgid, va_list *ap) |
bool | emit_diagnostic_valist_meta (diagnostic_t kind, rich_location *richloc, const diagnostic_metadata *metadata, diagnostic_option_id option_id, const char *gmsgid, va_list *ap) |
void | inform (location_t location, const char *gmsgid,...) |
void | inform (rich_location *richloc, const char *gmsgid,...) |
void | inform_n (location_t location, unsigned HOST_WIDE_INT n, const char *singular_gmsgid, const char *plural_gmsgid,...) |
bool | warning (diagnostic_option_id option_id, const char *gmsgid,...) |
bool | warning_at (location_t location, diagnostic_option_id option_id, const char *gmsgid,...) |
bool | warning_at (rich_location *richloc, diagnostic_option_id option_id, const char *gmsgid,...) |
bool | warning_meta (rich_location *richloc, const diagnostic_metadata &metadata, diagnostic_option_id option_id, const char *gmsgid,...) |
bool | warning_n (rich_location *richloc, diagnostic_option_id option_id, unsigned HOST_WIDE_INT n, const char *singular_gmsgid, const char *plural_gmsgid,...) |
bool | warning_n (location_t location, diagnostic_option_id option_id, unsigned HOST_WIDE_INT n, const char *singular_gmsgid, const char *plural_gmsgid,...) |
bool | pedwarn (location_t location, diagnostic_option_id option_id, const char *gmsgid,...) |
bool | pedwarn (rich_location *richloc, diagnostic_option_id option_id, const char *gmsgid,...) |
bool | permerror (location_t location, const char *gmsgid,...) |
bool | permerror (rich_location *richloc, const char *gmsgid,...) |
bool | permerror_opt (location_t location, diagnostic_option_id option_id, const char *gmsgid,...) |
bool | permerror_opt (rich_location *richloc, diagnostic_option_id option_id, const char *gmsgid,...) |
void | error (const char *gmsgid,...) |
void | error_n (location_t location, unsigned HOST_WIDE_INT n, const char *singular_gmsgid, const char *plural_gmsgid,...) |
void | error_at (location_t loc, const char *gmsgid,...) |
void | error_at (rich_location *richloc, const char *gmsgid,...) |
void | error_meta (rich_location *richloc, const diagnostic_metadata &metadata, const char *gmsgid,...) |
void | sorry (const char *gmsgid,...) |
void | sorry_at (location_t loc, const char *gmsgid,...) |
bool | seen_error (void) |
void | fatal_error (location_t loc, const char *gmsgid,...) |
void | internal_error (const char *gmsgid,...) |
void | internal_error_no_backtrace (const char *gmsgid,...) |
void | fnotice (FILE *file, const char *cmsgid,...) |
Variables | |
static diagnostic_context | global_diagnostic_context |
diagnostic_context * | global_dc = &global_diagnostic_context |
bool emit_diagnostic | ( | diagnostic_t | kind, |
location_t | location, | ||
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Wrapper around diagnostic_context::diagnostic_impl implying global_dc and taking a variable argument list.
References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.
bool emit_diagnostic | ( | diagnostic_t | kind, |
rich_location * | richloc, | ||
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
As above, but for rich_location *.
References ap, diagnostic_context::diagnostic_impl(), and global_dc.
bool emit_diagnostic_valist | ( | diagnostic_t | kind, |
location_t | location, | ||
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
va_list * | ap ) |
As above, but taking a variable argument list.
References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.
bool emit_diagnostic_valist_meta | ( | diagnostic_t | kind, |
rich_location * | richloc, | ||
const diagnostic_metadata * | metadata, | ||
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
va_list * | ap ) |
As above, but with rich_location and metadata.
References ap, diagnostic_context::diagnostic_impl(), and global_dc.
void error | ( | const char * | gmsgid, |
... ) |
A hard error: the code is definitely ill-formed, and an object file will not be produced.
References ap, diagnostic_context::diagnostic_impl(), global_dc, input_location, and line_table.
void error_at | ( | location_t | loc, |
const char * | gmsgid, | ||
... ) |
Same as above, but use location LOC instead of input_location.
References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.
void error_at | ( | rich_location * | richloc, |
const char * | gmsgid, | ||
... ) |
Same as above, but use RICH_LOC.
References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.
void error_meta | ( | rich_location * | richloc, |
const diagnostic_metadata & | metadata, | ||
const char * | gmsgid, | ||
... ) |
Same as above, but with metadata.
References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.
void error_n | ( | location_t | location, |
unsigned HOST_WIDE_INT | n, | ||
const char * | singular_gmsgid, | ||
const char * | plural_gmsgid, | ||
... ) |
A hard error: the code is definitely ill-formed, and an object file will not be produced.
References ap, diagnostic_context::diagnostic_n_impl(), global_dc, and line_table.
void fatal_error | ( | location_t | loc, |
const char * | gmsgid, | ||
... ) |
An error which is severe enough that we make no attempt to continue. Do not use this for internal consistency checks; that's internal_error. Use of this function should be rare.
References ap, diagnostic_context::diagnostic_impl(), gcc_unreachable, global_dc, and line_table.
void fnotice | ( | FILE * | file, |
const char * | cmsgid, | ||
... ) |
Special case error functions. Most are implemented in terms of the above, or should be.
Print a diagnostic MSGID on FILE. This is just fprintf, except it runs its second argument through gettext.
References _, ap, global_dc, diagnostic_context::supports_fnotice_on_stderr_p(), and vfprintf().
Referenced by diagnostic_context::action_after_output(), add_line_counts(), diagnostic_context::check_max_errors(), check_repro(), do_merge_stream(), do_report_bug(), do_rewrite(), do_spec_1(), emergency_dump_function(), diagnostic_context::error_recursion(), execute(), executed_summary(), fancy_abort(), file_summary(), find_source(), function_summary(), generate_results(), init_spec(), load_specs(), merge_stream_usage(), merge_usage(), sarif_builder::on_report_diagnostic(), output_branch_count(), output_conditions(), output_gcov_file(), overlap_usage(), print_configuration(), print_merge_stream_usage_message(), print_merge_usage_message(), print_overlap_usage_message(), print_rewrite_usage_message(), print_usage(), print_usage(), print_version(), print_version(), process_file(), profile_merge(), read_count_file(), read_graph_file(), read_specs(), diagnostic_context::report_diagnostic(), rewrite_usage(), set_spec(), slurp(), solve_flow_graph(), try_generate_repro(), warn_if_plugins(), env_manager::xput(), and json_file_output_format::~json_file_output_format().
void inform | ( | location_t | location, |
const char * | gmsgid, | ||
... ) |
An informative note at LOCATION. Use this for additional details on an error message.
References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.
void inform | ( | rich_location * | richloc, |
const char * | gmsgid, | ||
... ) |
Same as "inform" above, but at RICHLOC.
References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.
void inform_n | ( | location_t | location, |
unsigned HOST_WIDE_INT | n, | ||
const char * | singular_gmsgid, | ||
const char * | plural_gmsgid, | ||
... ) |
An informative note at LOCATION. Use this for additional details on an error message.
References ap, diagnostic_context::diagnostic_n_impl(), global_dc, and line_table.
void internal_error | ( | const char * | gmsgid, |
... ) |
An internal consistency check has failed. We make no attempt to continue.
References ap, diagnostic_context::diagnostic_impl(), gcc_unreachable, global_dc, input_location, and line_table.
void internal_error_no_backtrace | ( | const char * | gmsgid, |
... ) |
Like internal_error, but no backtrace will be printed. Used when the internal error does not happen at the current location, but happened somewhere else.
References ap, diagnostic_context::diagnostic_impl(), gcc_unreachable, global_dc, input_location, and line_table.
bool pedwarn | ( | location_t | location, |
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
A "pedantic" warning at LOCATION: issues a warning unless -pedantic-errors was given on the command line, in which case it issues an error. Use this for diagnostics required by the relevant language standard, if you have chosen not to make them errors. Note that these diagnostics are issued independent of the setting of the -Wpedantic command-line switch. To get a warning enabled only with that switch, use either "if (pedantic) pedwarn (OPT_Wpedantic,...)" or just "pedwarn (OPT_Wpedantic,..)". To get a pedwarn independently of the -Wpedantic switch use "pedwarn (0,...)". Returns true if the warning was printed, false if it was inhibited.
References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.
bool pedwarn | ( | rich_location * | richloc, |
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Same as pedwarn above, but using RICHLOC.
References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.
bool permerror | ( | location_t | location, |
const char * | gmsgid, | ||
... ) |
A "permissive" error at LOCATION: issues an error unless -fpermissive was given on the command line, in which case it issues a warning. Use this for things that really should be errors but we want to support legacy code. Returns true if the warning was printed, false if it was inhibited.
References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.
bool permerror | ( | rich_location * | richloc, |
const char * | gmsgid, | ||
... ) |
Same as "permerror" above, but at RICHLOC.
References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.
bool permerror_opt | ( | location_t | location, |
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Similar to the above, but controlled by a flag other than -fpermissive. As above, an error by default or a warning with -fpermissive, but this diagnostic can also be downgraded by -Wno-error=opt.
References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.
bool permerror_opt | ( | rich_location * | richloc, |
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Same as "permerror" above, but at RICHLOC.
References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.
bool seen_error | ( | void | ) |
Return true if an error or a "sorry" has been seen on global_dc. Various processing is disabled after errors.
References errorcount, and sorrycount.
Referenced by analyze_functions(), asan_emit_stack_protection(), symbol_table::compile(), compile_file(), do_assemble_alias(), do_compile(), driver::do_spec_on_infiles(), early_inliner(), execute_function_todo(), expand_BUILTIN_EXPECT(), expand_builtin_expect(), expand_builtin_expect_with_probability(), driver::final_actions(), finalize(), symbol_table::finalize_compilation_unit(), gate_lto_out(), get_coverage_counts(), driver::get_exit_code(), gimple_push_cleanup(), gimplify_body(), gimplify_call_expr(), gimplify_omp_for(), gimplify_omp_loop_xform(), gimplify_var_or_parm_decl(), ipa_passes(), ipa_write_summaries(), label_to_block(), lower_omp_1(), main(), toplev::main(), driver::maybe_run_linker(), oacc_xform_tile(), omp_group_base(), symbol_table::output_variables(), driver::prepare_infiles(), symbol_table::remove_unreferenced_decls(), reset_dies(), rest_of_decl_compilation(), rest_of_type_compilation(), scan_omp_1_stmt(), scan_sharing_clauses(), symtab_node::verify(), cgraph_node::verify_cgraph_nodes(), and cgraph_node::verify_node().
void sorry | ( | const char * | gmsgid, |
... ) |
"Sorry, not implemented." Use for a language feature which is required by the relevant specification but not implemented by GCC. An object file will not be produced.
References ap, diagnostic_context::diagnostic_impl(), global_dc, input_location, and line_table.
void sorry_at | ( | location_t | loc, |
const char * | gmsgid, | ||
... ) |
Same as above, but use location LOC instead of input_location.
References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.
void verbatim | ( | const char * | gmsgid, |
... ) |
Standard error reporting routines in increasing order of severity.
Text to be emitted verbatim to the error message stream; this produces no prefix and disables line-wrapping. Use rarely. It is ignored for machine-readable output formats.
References _, ap, errno, global_dc, and diagnostic_context::report_verbatim().
bool warning | ( | diagnostic_option_id | option_id, |
const char * | gmsgid, | ||
... ) |
A warning at INPUT_LOCATION. Use this for code which is correct according to the relevant language specification but is likely to be buggy anyway. Returns true if the warning was printed, false if it was inhibited.
References ap, diagnostic_context::diagnostic_impl(), global_dc, input_location, and line_table.
bool warning_at | ( | location_t | location, |
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
A warning at LOCATION. Use this for code which is correct according to the relevant language specification but is likely to be buggy anyway. Returns true if the warning was printed, false if it was inhibited.
References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.
bool warning_at | ( | rich_location * | richloc, |
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Same as "warning at" above, but using RICHLOC.
References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.
bool warning_meta | ( | rich_location * | richloc, |
const diagnostic_metadata & | metadata, | ||
diagnostic_option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Same as "warning at" above, but using METADATA.
References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.
bool warning_n | ( | location_t | location, |
diagnostic_option_id | option_id, | ||
unsigned HOST_WIDE_INT | n, | ||
const char * | singular_gmsgid, | ||
const char * | plural_gmsgid, | ||
... ) |
A warning at LOCATION. Use this for code which is correct according to the relevant language specification but is likely to be buggy anyway. Returns true if the warning was printed, false if it was inhibited.
References ap, diagnostic_context::diagnostic_n_impl(), global_dc, and line_table.
bool warning_n | ( | rich_location * | richloc, |
diagnostic_option_id | option_id, | ||
unsigned HOST_WIDE_INT | n, | ||
const char * | singular_gmsgid, | ||
const char * | plural_gmsgid, | ||
... ) |
Same as warning_n plural variant below, but using RICHLOC.
References ap, diagnostic_context::diagnostic_n_impl(), gcc_assert, and global_dc.
diagnostic_context* global_dc = &global_diagnostic_context |
This diagnostic_context is used by front-ends that directly output diagnostic messages without going through `error', `warning', and similar functions.
Referenced by gcc_rich_location::add_fixit_insert_formatted(), announce_function(), attr_access::array_as_string(), asm_show_source(), auto_diagnostic_group::auto_diagnostic_group(), auto_diagnostic_nesting_level::auto_diagnostic_nesting_level(), auto_override_urlifier::auto_override_urlifier(), diagnostic_for_asm(), do_self_spec(), driver_handle_option(), emit_diagnostic(), emit_diagnostic(), emit_diagnostic_valist(), emit_diagnostic_valist_meta(), format_string_diagnostic_t::emit_warning_n_va(), error(), error_at(), error_at(), error_meta(), error_n(), escaped_string::escape(), fancy_abort(), fatal_error(), driver::finalize(), fnotice(), general_init(), driver::global_initializations(), inform(), inform(), inform_n(), init_asm_output(), init_options_once(), internal_error(), internal_error_function(), internal_error_no_backtrace(), lang_handle_option(), main(), main(), main(), toplev::main(), option_unspecified_p(), pedwarn(), pedwarn(), permerror(), permerror(), permerror_opt(), permerror_opt(), print_lto_docs_link(), process_command(), process_options(), run_gcc(), sorry(), sorry_at(), target_handle_option(), tree_dump_pretty_printer::tree_dump_pretty_printer(), verbatim(), warning(), warning_at(), warning_at(), warning_enabled_at(), warning_meta(), warning_n(), warning_n(), auto_diagnostic_group::~auto_diagnostic_group(), auto_diagnostic_nesting_level::~auto_diagnostic_nesting_level(), and auto_override_urlifier::~auto_override_urlifier().
|
static |
Language-independent diagnostic subroutines that implicitly use global_dc. Copyright (C) 1999-2024 Free Software Foundation, Inc. Contributed by Gabriel Dos Reis <gdr@codesourcery.com> 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/>.
This file implements the parts of the language independent aspect of diagnostic messages that implicitly use global_dc.
A diagnostic_context surrogate for stderr.