GCC Middle and Back End API Reference
|
Functions | |
static char * | build_message_string (const char *,...) |
char * | file_name_as_prefix () |
static int | getenv_columns () |
void | diagnostic_set_caret_max_width () |
void | diagnostic_initialize () |
void | diagnostic_finish () |
void | diagnostic_set_info_translated (diagnostic_info *diagnostic, const char *msg, va_list *args, location_t location, diagnostic_t kind) |
void | diagnostic_set_info (diagnostic_info *diagnostic, const char *gmsgid, va_list *args, location_t location, diagnostic_t kind) |
char * | diagnostic_build_prefix (diagnostic_context *context, const diagnostic_info *diagnostic) |
static const char * | adjust_line () |
void | diagnostic_show_locus (diagnostic_context *context, const diagnostic_info *diagnostic) |
static int | bt_callback (void *data, uintptr_t pc, const char *filename, int lineno, const char *function) |
static void | bt_err_callback () |
static void | diagnostic_action_after_output (diagnostic_context *context, diagnostic_info *diagnostic) |
void | diagnostic_report_current_module () |
void | default_diagnostic_starter (diagnostic_context *context, diagnostic_info *diagnostic) |
void | default_diagnostic_finalizer (diagnostic_context *context, diagnostic_info *diagnostic) |
diagnostic_t | diagnostic_classify_diagnostic (diagnostic_context *context, int option_index, diagnostic_t new_kind, location_t where) |
void | diagnostic_push_diagnostics () |
void | diagnostic_pop_diagnostics () |
bool | diagnostic_report_diagnostic (diagnostic_context *context, diagnostic_info *diagnostic) |
const char * | trim_filename () |
void | verbatim () |
void | diagnostic_append_note (diagnostic_context *context, location_t location, const char *gmsgid,...) |
bool | emit_diagnostic (diagnostic_t kind, location_t location, int opt, const char *gmsgid,...) |
void | inform () |
void | inform_n (location_t location, int n, const char *singular_gmsgid, const char *plural_gmsgid,...) |
bool | warning () |
bool | warning_at () |
bool | pedwarn () |
bool | permerror () |
void | error () |
void | error_n (location_t location, int n, const char *singular_gmsgid, const char *plural_gmsgid,...) |
void | error_at () |
void | sorry () |
bool | seen_error () |
void | fatal_error () |
void | internal_error () |
void | fnotice () |
static void | error_recursion () |
void | fancy_abort () |
static void | real_abort () |
Variables | |
static const char *const | bt_stop [] |
|
static |
If LINE is longer than MAX_WIDTH, and COLUMN is not smaller than MAX_WIDTH by some margin, then adjust the start of the line such that the COLUMN is smaller than MAX_WIDTH minus the margin. The margin is either 10 characters or the difference between the column and the length of the line, whatever is smaller.
References strlen().
Referenced by diagnostic_show_locus().
|
static |
A callback function passed to the backtrace_full function.
References bt_stop, free(), len, and strlen().
Referenced by diagnostic_action_after_output().
|
static |
A callback function passed to the backtrace_full function. This is called if backtrace_full has an error.
Referenced by diagnostic_action_after_output().
|
static |
Prototypes.
Return a malloc'd string containing MSG formatted a la printf. The caller is responsible for freeing the memory.
Referenced by diagnostic_build_prefix(), and file_name_as_prefix().
void default_diagnostic_finalizer | ( | diagnostic_context * | context, |
diagnostic_info * | diagnostic | ||
) |
Referenced by diagnostic_initialize(), and tree_diagnostics_defaults().
void default_diagnostic_starter | ( | diagnostic_context * | context, |
diagnostic_info * | diagnostic | ||
) |
References diagnostic_build_prefix(), diagnostic_report_current_module(), diagnostic_info::location, pp_set_prefix(), and diagnostic_context::printer.
Referenced by diagnostic_initialize().
|
static |
Take any action which is expected to happen after the diagnostic is written out. This function does not always return.
References diagnostic_context::abort_on_error, bt_callback(), bt_err_callback(), bug_report_url, count, diagnostic_finish(), diagnostic_context::fatal_errors, fnotice(), diagnostic_info::kind, diagnostic_context::max_errors, and real_abort().
Referenced by diagnostic_report_diagnostic(), and error_recursion().
void diagnostic_append_note | ( | diagnostic_context * | context, |
location_t | location, | ||
const char * | gmsgid, | ||
... | |||
) |
Add a note with text GMSGID and with LOCATION to the diagnostic CONTEXT.
References diagnostic_build_prefix(), diagnostic_set_info(), diagnostic_show_locus(), diagnostic_context::inhibit_notes_p, diagnostic_info::message, pp_destroy_prefix(), pp_format(), pp_get_prefix(), pp_newline(), pp_output_formatted_text(), pp_set_prefix(), and diagnostic_context::printer.
Referenced by maybe_unwind_expanded_macro_loc().
char* diagnostic_build_prefix | ( | diagnostic_context * | context, |
const diagnostic_info * | diagnostic | ||
) |
Return a malloc'd string describing a location. The caller is responsible for freeing the memory.
References build_message_string(), colorize_start(), colorize_stop(), DK_LAST_DIAGNOSTIC_KIND, expand_location_to_spelling_point(), diagnostic_info::kind, diagnostic_info::location, diagnostic_info::override_column, diagnostic_context::printer, progname, and diagnostic_context::show_column.
Referenced by default_diagnostic_starter(), default_tree_diagnostic_starter(), and diagnostic_append_note().
diagnostic_t diagnostic_classify_diagnostic | ( | diagnostic_context * | context, |
int | option_index, | ||
diagnostic_t | new_kind, | ||
location_t | where | ||
) |
Interface to specify diagnostic kind overrides. Returns the previous setting, or DK_UNSPECIFIED if the parameters are out of range. If OPTION_INDEX is zero, the new setting is for all the diagnostics.
References diagnostic_context::classification_history, diagnostic_context::classify_diagnostic, DK_LAST_DIAGNOSTIC_KIND, diagnostic_classification_change_t::kind, diagnostic_classification_change_t::location, diagnostic_context::n_classification_history, diagnostic_context::n_opts, and diagnostic_classification_change_t::option.
Referenced by control_warning_option(), process_options(), and set_option().
void diagnostic_finish | ( | ) |
Do any cleaning up required after the last diagnostic is emitted.
References pp_newline_and_flush(), pp_verbatim(), diagnostic_context::printer, progname, diagnostic_context::some_warnings_are_errors, and diagnostic_context::warning_as_error_requested.
Referenced by diagnostic_action_after_output(), and toplev_main().
void diagnostic_initialize | ( | ) |
Initialize the diagnostic message outputting machinery.
References diagnostic_context::abort_on_error, diagnostic_context::classify_diagnostic, diagnostic_context::dc_inhibit_warnings, diagnostic_context::dc_warn_system_headers, default_diagnostic_finalizer(), default_diagnostic_starter(), diagnostic_context::diagnostic_count, diagnostic_set_caret_max_width(), diagnostic_context::fatal_errors, diagnostic_context::inhibit_notes_p, diagnostic_context::internal_error, diagnostic_context::last_location, diagnostic_context::last_module, diagnostic_context::lock, diagnostic_context::max_errors, memset(), diagnostic_context::n_opts, diagnostic_context::opt_permissive, diagnostic_context::option_enabled, diagnostic_context::option_name, diagnostic_context::option_state, diagnostic_context::pedantic_errors, diagnostic_context::permissive, diagnostic_context::printer, diagnostic_context::show_caret, diagnostic_context::show_column, diagnostic_context::show_option_requested, diagnostic_context::some_warnings_are_errors, diagnostic_context::warning_as_error_requested, and diagnostic_context::x_data.
Referenced by general_init(), main(), and print_usage().
void diagnostic_pop_diagnostics | ( | ) |
Restore the topmost classification set off the stack. If the stack is empty, revert to the state based on command line parameters.
References diagnostic_context::classification_history, DK_POP, diagnostic_classification_change_t::kind, diagnostic_classification_change_t::location, diagnostic_context::n_classification_history, diagnostic_context::n_push, diagnostic_classification_change_t::option, and diagnostic_context::push_list.
void diagnostic_push_diagnostics | ( | ) |
Save all diagnostic classifications in a stack.
References diagnostic_context::n_classification_history, diagnostic_context::n_push, and diagnostic_context::push_list.
void diagnostic_report_current_module | ( | ) |
References line_table, map, pp_newline(), pp_verbatim(), diagnostic_context::printer, and diagnostic_context::show_column.
Referenced by default_diagnostic_starter(), and diagnostic_report_current_function().
bool diagnostic_report_diagnostic | ( | diagnostic_context * | context, |
diagnostic_info * | diagnostic | ||
) |
Report a diagnostic message (an error or a warning) as specified by DC. This function is *the* subroutine in terms of which front-ends should implement their specific diagnostic handling modules. The front-end independent format specifiers are exactly those described in the documentation of output_format. Return true if a diagnostic was printed, false otherwise.
References diagnostic_context::abort_on_error, text_info::args_ptr, diagnostic_context::classification_history, diagnostic_context::classify_diagnostic, diagnostic_action_after_output(), diagnostic_show_locus(), DK_POP, error_recursion(), expand_location(), fnotice(), text_info::format_spec, free(), diagnostic_context::inhibit_notes_p, diagnostic_context::internal_error, diagnostic_info::kind, diagnostic_classification_change_t::kind, line_table, diagnostic_info::location, diagnostic_classification_change_t::location, diagnostic_context::lock, text_info::locus, diagnostic_info::message, diagnostic_context::n_classification_history, diagnostic_classification_change_t::option, option(), diagnostic_context::option_enabled, diagnostic_info::option_index, diagnostic_context::option_name, diagnostic_context::option_state, pp_destroy_prefix(), pp_format(), pp_newline_and_flush(), pp_output_formatted_text(), diagnostic_context::printer, diagnostic_context::show_option_requested, diagnostic_context::some_warnings_are_errors, diagnostic_context::warning_as_error_requested, diagnostic_info::x_data, and text_info::x_data.
void diagnostic_set_caret_max_width | ( | ) |
Set caret_max_width to value.
References diagnostic_context::caret_max_width, getenv_columns(), and diagnostic_context::printer.
Referenced by common_handle_option(), and diagnostic_initialize().
void diagnostic_set_info | ( | diagnostic_info * | diagnostic, |
const char * | gmsgid, | ||
va_list * | args, | ||
location_t | location, | ||
diagnostic_t | kind | ||
) |
Initialize DIAGNOSTIC, where the message GMSGID has not yet been translated.
References diagnostic_set_info_translated().
Referenced by diagnostic_append_note(), emit_diagnostic(), error(), error_at(), fatal_error(), inform(), internal_error(), pedwarn(), permerror(), sorry(), warning(), and warning_at().
void diagnostic_set_info_translated | ( | diagnostic_info * | diagnostic, |
const char * | msg, | ||
va_list * | args, | ||
location_t | location, | ||
diagnostic_t | kind | ||
) |
Initialize DIAGNOSTIC, where the message MSG has already been translated.
References text_info::args_ptr, text_info::err_no, errno, text_info::format_spec, diagnostic_info::kind, diagnostic_info::location, diagnostic_info::message, diagnostic_info::option_index, and diagnostic_info::override_column.
Referenced by diagnostic_set_info(), error_n(), and inform_n().
void diagnostic_show_locus | ( | diagnostic_context * | context, |
const diagnostic_info * | diagnostic | ||
) |
Print the physical source line corresponding to the location of this diagnostics, and a caret indicating the precise column.
References adjust_line(), buffer, diagnostic_context::caret_max_width, colorize_start(), colorize_stop(), expand_location_to_spelling_point(), diagnostic_context::last_location, len, diagnostic_info::location, location_get_source_line(), pp_character(), pp_get_prefix(), pp_newline(), pp_set_prefix(), pp_string(), diagnostic_context::printer, diagnostic_context::show_caret, snprintf(), and strlen().
Referenced by diagnostic_append_note(), and diagnostic_report_diagnostic().
bool emit_diagnostic | ( | diagnostic_t | kind, |
location_t | location, | ||
int | opt, | ||
const char * | gmsgid, | ||
... | |||
) |
References diagnostic_set_info(), global_dc, and diagnostic_info::option_index.
void error | ( | ) |
A hard error: the code is definitely ill-formed, and an object file will not be produced.
References diagnostic_set_info(), and input_location.
void error_at | ( | ) |
Same as ebove, but use location LOC instead of input_location.
References diagnostic_set_info().
void error_n | ( | location_t | location, |
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 diagnostic_set_info_translated().
|
static |
Inform the user that an error occurred while trying to report some other error. This indicates catastrophic internal inconsistencies, so give up now. But do try to flush out the previous error. This mustn't use internal_error, that will cause infinite recursion.
References diagnostic_action_after_output(), fnotice(), diagnostic_info::kind, diagnostic_context::lock, pp_newline_and_flush(), diagnostic_context::printer, and real_abort().
Referenced by diagnostic_report_diagnostic().
void fancy_abort | ( | ) |
Report an internal compiler error in a friendly manner. This is the function that gets called upon use of abort() in the source code generally, thanks to a special macro.
References internal_error(), and trim_filename().
Referenced by _fatal_insn().
void fatal_error | ( | ) |
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 diagnostic_set_info(), and input_location.
char* file_name_as_prefix | ( | ) |
Same as diagnostic_build_prefix, but only the source FILE is given.
References build_message_string(), colorize_start(), colorize_stop(), and diagnostic_context::printer.
Referenced by lhd_print_error_function().
void fnotice | ( | ) |
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.
|
static |
Return the value of the getenv("COLUMNS") as an integer. If the value is not set to a positive integer, then return INT_MAX.
References getenv().
Referenced by diagnostic_set_caret_max_width().
void inform | ( | ) |
An informative note at LOCATION. Use this for additional details on an error message.
References diagnostic_set_info().
void inform_n | ( | location_t | location, |
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 diagnostic_set_info_translated().
void internal_error | ( | ) |
An internal consistency check has failed. We make no attempt to continue. Note that unless there is debugging value to be had from a more specific message, or some other good reason, you should use abort () instead of calling this function directly.
References diagnostic_set_info(), and input_location.
bool pedwarn | ( | ) |
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 diagnostic_set_info(), and diagnostic_info::option_index.
bool permerror | ( | ) |
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 diagnostic_set_info(), global_dc, and diagnostic_info::option_index.
|
static |
Really call the system 'abort'. This has to go right at the end of this file, so that there are no functions after it that call abort and get the system abort instead of our macro.
References abort().
Referenced by diagnostic_action_after_output(), and error_recursion().
bool seen_error | ( | void | ) |
Return true if an error or a "sorry" has been seen. Various processing is disabled after errors.
Referenced by compile(), compile_file(), do_compile(), dwarf2out_finish(), early_inliner(), emit_debug_global_declarations(), execute_function_todo(), expand_builtin_expect(), finalize(), gate_all_early_local_passes(), gate_all_early_optimizations(), gate_expand_omp(), gate_ipa_pta(), gate_lto_out(), gate_pure_const(), gate_reference(), gate_rest_of_compilation(), get_coverage_counts(), gimple_push_cleanup(), gimplify_body(), gimplify_var_or_parm_decl(), ipa_passes(), ipa_write_summaries(), label_to_block_fn(), lower_omp_1(), main(), mudflap_finish_file(), output_asm_statements(), rest_of_decl_compilation(), rest_of_type_compilation(), toplev_main(), varpool_output_variables(), varpool_remove_unreferenced_decls(), verify_cgraph(), verify_cgraph_node(), and verify_symtab_node().
void sorry | ( | ) |
"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 diagnostic_set_info(), and input_location.
const char* trim_filename | ( | ) |
Given a partial pathname as input, return another pathname that shares no directory elements with the pathname of __FILE__. This is used by fancy_abort() to print `Internal compiler error in expr.c' instead of `Internal compiler error in ../../GCC/gcc/expr.c'.
References this_file.
void verbatim | ( | ) |
Standard error reporting routines in increasing order of severity. All of these take arguments like printf.
Text to be emitted verbatim to the error message stream; this produces no prefix and disables line-wrapping. Use rarely.
References text_info::args_ptr, text_info::err_no, errno, text_info::format_spec, global_dc, text_info::locus, pp_format_verbatim(), pp_newline_and_flush(), diagnostic_context::printer, and text_info::x_data.
bool warning | ( | ) |
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 diagnostic_set_info(), input_location, and diagnostic_info::option_index.
bool warning_at | ( | ) |
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 diagnostic_set_info(), and diagnostic_info::option_index.
|
static |
Functions at which to stop the backtrace print. It's not particularly helpful to print the callers of these functions.
Referenced by bt_callback().