GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "intl.h"
#include "diagnostic.h"
#include "diagnostics/sink.h"
#include "diagnostics/logging.h"
Typedefs | |
using | log_function_params = diagnostics::logging::log_function_params |
using | auto_inc_log_depth = diagnostics::logging::auto_inc_depth |
Functions | |
void | verbatim (const char *gmsgid,...) |
bool | emit_diagnostic (enum diagnostics::kind kind, location_t location, diagnostics::option_id option_id, const char *gmsgid,...) |
bool | emit_diagnostic (enum diagnostics::kind kind, rich_location *richloc, diagnostics::option_id option_id, const char *gmsgid,...) |
bool | emit_diagnostic_valist (enum diagnostics::kind kind, location_t location, diagnostics::option_id option_id, const char *gmsgid, va_list *ap) |
bool | emit_diagnostic_valist_meta (enum diagnostics::kind kind, rich_location *richloc, const diagnostics::metadata *metadata, diagnostics::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 (diagnostics::option_id option_id, const char *gmsgid,...) |
bool | warning_at (location_t location, diagnostics::option_id option_id, const char *gmsgid,...) |
bool | warning_at (rich_location *richloc, diagnostics::option_id option_id, const char *gmsgid,...) |
bool | warning_meta (rich_location *richloc, const diagnostics::metadata &metadata, diagnostics::option_id option_id, const char *gmsgid,...) |
bool | warning_n (rich_location *richloc, diagnostics::option_id option_id, unsigned HOST_WIDE_INT n, const char *singular_gmsgid, const char *plural_gmsgid,...) |
bool | warning_n (location_t location, diagnostics::option_id option_id, unsigned HOST_WIDE_INT n, const char *singular_gmsgid, const char *plural_gmsgid,...) |
bool | pedwarn (location_t location, diagnostics::option_id option_id, const char *gmsgid,...) |
bool | pedwarn (rich_location *richloc, diagnostics::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, diagnostics::option_id option_id, const char *gmsgid,...) |
bool | permerror_opt (rich_location *richloc, diagnostics::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 diagnostics::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 diagnostics::context | global_diagnostic_context |
diagnostics::context * | global_dc = &global_diagnostic_context |
bool emit_diagnostic | ( | enum diagnostics::kind | kind, |
location_t | location, | ||
diagnostics::option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Wrapper around diagnostics::context::diagnostic_impl implying global_dc and taking a variable argument list.
References ap, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), diagnostics::logging::log_function_params::log_param_option_id(), and diagnostics::logging::log_function_params::log_param_string().
bool emit_diagnostic | ( | enum diagnostics::kind | kind, |
rich_location * | richloc, | ||
diagnostics::option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
As above, but for rich_location *.
References ap, global_dc, diagnostics::logging::log_function_params::log_param_option_id(), diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_param_string().
bool emit_diagnostic_valist | ( | enum diagnostics::kind | kind, |
location_t | location, | ||
diagnostics::option_id | option_id, | ||
const char * | gmsgid, | ||
va_list * | ap ) |
As above, but taking a variable argument list.
References ap, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), diagnostics::logging::log_function_params::log_param_option_id(), and diagnostics::logging::log_function_params::log_param_string().
bool emit_diagnostic_valist_meta | ( | enum diagnostics::kind | kind, |
rich_location * | richloc, | ||
const diagnostics::metadata * | metadata, | ||
diagnostics::option_id | option_id, | ||
const char * | gmsgid, | ||
va_list * | ap ) |
As above, but with rich_location and metadata.
References ap, global_dc, diagnostics::logging::log_function_params::log_param_option_id(), diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_param_string().
void error | ( | const char * | gmsgid, |
... ) |
A hard error: the code is definitely ill-formed, and an object file will not be produced.
References ap, global_dc, input_location, line_table, and diagnostics::logging::log_function_params::log_param_string().
void error_at | ( | location_t | loc, |
const char * | gmsgid, | ||
... ) |
Same as above, but use location LOC instead of input_location.
References ap, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), and diagnostics::logging::log_function_params::log_param_string().
void error_at | ( | rich_location * | richloc, |
const char * | gmsgid, | ||
... ) |
Same as above, but use RICH_LOC.
References ap, gcc_assert, global_dc, diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_param_string().
void error_meta | ( | rich_location * | richloc, |
const diagnostics::metadata & | metadata, | ||
const char * | gmsgid, | ||
... ) |
Same as above, but with metadata.
References ap, gcc_assert, global_dc, diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_param_string().
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, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), and diagnostics::logging::log_function_params::log_params_n_gmsgids().
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, gcc_unreachable, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), and diagnostics::logging::log_function_params::log_param_string().
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, and vfprintf().
Referenced by diagnostics::context::action_after_output(), add_line_counts(), diagnostics::context::check_max_errors(), check_repro(), do_merge_stream(), do_report_bug(), do_rewrite(), do_spec_1(), emergency_dump_function(), diagnostics::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(), diagnostics::html_builder::on_report_diagnostic(), diagnostics::sarif_builder::on_report_diagnostic(), output_branch_count(), output_conditions(), output_gcov_file(), output_path_coverage(), 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_args(), process_file(), profile_merge(), read_count_file(), read_graph_file(), read_specs(), diagnostics::context::report_diagnostic(), rewrite_usage(), set_spec(), slurp(), solve_flow_graph(), try_generate_repro(), warn_if_plugins(), and env_manager::xput().
void inform | ( | location_t | location, |
const char * | gmsgid, | ||
... ) |
An informative note at LOCATION. Use this for additional details on an error message.
References ap, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), and diagnostics::logging::log_function_params::log_param_string().
void inform | ( | rich_location * | richloc, |
const char * | gmsgid, | ||
... ) |
Same as "inform" above, but at RICHLOC.
References ap, gcc_assert, global_dc, diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_param_string().
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, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), and diagnostics::logging::log_function_params::log_params_n_gmsgids().
void internal_error | ( | const char * | gmsgid, |
... ) |
An internal consistency check has failed. We make no attempt to continue.
References ap, gcc_unreachable, global_dc, input_location, line_table, and diagnostics::logging::log_function_params::log_param_string().
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, gcc_unreachable, global_dc, input_location, line_table, and diagnostics::logging::log_function_params::log_param_string().
bool pedwarn | ( | location_t | location, |
diagnostics::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, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), diagnostics::logging::log_function_params::log_param_option_id(), and diagnostics::logging::log_function_params::log_param_string().
bool pedwarn | ( | rich_location * | richloc, |
diagnostics::option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Same as pedwarn above, but using RICHLOC.
References ap, gcc_assert, global_dc, diagnostics::logging::log_function_params::log_param_option_id(), diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_param_string().
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, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), and diagnostics::logging::log_function_params::log_param_string().
bool permerror | ( | rich_location * | richloc, |
const char * | gmsgid, | ||
... ) |
Same as "permerror" above, but at RICHLOC.
References ap, gcc_assert, global_dc, diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_param_string().
bool permerror_opt | ( | location_t | location, |
diagnostics::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, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), diagnostics::logging::log_function_params::log_param_option_id(), and diagnostics::logging::log_function_params::log_param_string().
bool permerror_opt | ( | rich_location * | richloc, |
diagnostics::option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Same as "permerror" above, but at RICHLOC.
References ap, gcc_assert, global_dc, diagnostics::logging::log_function_params::log_param_option_id(), diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_param_string().
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(), emit_diagnostic_valist_meta(), 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, global_dc, input_location, line_table, and diagnostics::logging::log_function_params::log_param_string().
void sorry_at | ( | location_t | loc, |
const char * | gmsgid, | ||
... ) |
Same as above, but use location LOC instead of input_location.
References ap, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), and diagnostics::logging::log_function_params::log_param_string().
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 diagnostics::logging::log_function_params::log_param_string().
bool warning | ( | diagnostics::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, global_dc, input_location, line_table, diagnostics::logging::log_function_params::log_param_option_id(), and diagnostics::logging::log_function_params::log_param_string().
bool warning_at | ( | location_t | location, |
diagnostics::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, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), diagnostics::logging::log_function_params::log_param_option_id(), and diagnostics::logging::log_function_params::log_param_string().
bool warning_at | ( | rich_location * | richloc, |
diagnostics::option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Same as "warning at" above, but using RICHLOC.
References ap, gcc_assert, global_dc, diagnostics::logging::log_function_params::log_param_option_id(), diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_param_string().
bool warning_meta | ( | rich_location * | richloc, |
const diagnostics::metadata & | metadata, | ||
diagnostics::option_id | option_id, | ||
const char * | gmsgid, | ||
... ) |
Same as "warning at" above, but using METADATA.
References ap, gcc_assert, global_dc, diagnostics::logging::log_function_params::log_param_option_id(), diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_param_string().
bool warning_n | ( | location_t | location, |
diagnostics::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, global_dc, line_table, diagnostics::logging::log_function_params::log_param_location_t(), diagnostics::logging::log_function_params::log_param_option_id(), and diagnostics::logging::log_function_params::log_params_n_gmsgids().
bool warning_n | ( | rich_location * | richloc, |
diagnostics::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, gcc_assert, global_dc, diagnostics::logging::log_function_params::log_param_option_id(), diagnostics::logging::log_function_params::log_param_rich_location(), and diagnostics::logging::log_function_params::log_params_n_gmsgids().
diagnostics::context* global_dc = &global_diagnostic_context |
This diagnostics::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(), text_art::dump_to_file(), 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(), lazy_diagnostic_context_path::make_inner_path(), 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-2025 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 diagnostics::context surrogate for stderr.