GCC Middle and Back End API Reference
diagnostic.c File 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 []

Function Documentation

static const char* adjust_line ( )
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 int bt_callback ( void *  data,
uintptr_t  pc,
const char *  filename,
int  lineno,
const char *  function 
)
static
A callback function passed to the backtrace_full function.   

References bt_stop, free(), len, and strlen().

Referenced by diagnostic_action_after_output().

static void bt_err_callback ( )
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 char* build_message_string ( const char *  ,
  ... 
)
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 
)
static void diagnostic_action_after_output ( diagnostic_context context,
diagnostic_info diagnostic 
)
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,
  ... 
)
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 ( )
void diagnostic_pop_diagnostics ( )
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.

bool diagnostic_report_diagnostic ( diagnostic_context context,
diagnostic_info diagnostic 
)
void diagnostic_set_caret_max_width ( )
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 
)
bool emit_diagnostic ( diagnostic_t  kind,
location_t  location,
int  opt,
const char *  gmsgid,
  ... 
)
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 void error_recursion ( )
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 int getenv_columns ( )
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 void real_abort ( )
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().

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.


Variable Documentation

const char* const bt_stop[]
static
Initial value:
{
"main",
"toplev_main",
"execute_one_pass",
"compile_file",
}
Functions at which to stop the backtrace print.  It's not
   particularly helpful to print the callers of these functions.   

Referenced by bt_callback().