GCC Middle and Back End API Reference
diagnostic.h File Reference
#include "pretty-print.h"
#include "diagnostic-core.h"
Include dependency graph for diagnostic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  diagnostic_info
struct  diagnostic_classification_change_t
struct  diagnostic_context

Macros

#define diagnostic_starter(DC)   (DC)->begin_diagnostic
#define diagnostic_finalizer(DC)   (DC)->end_diagnostic
#define diagnostic_context_auxiliary_data(DC)   (DC)->x_data
#define diagnostic_info_auxiliary_data(DI)   (DI)->x_data
#define diagnostic_format_decoder(DC)   ((DC)->printer->format_decoder)
#define diagnostic_prefixing_rule(DC)   ((DC)->printer->wrapping.rule)
#define diagnostic_line_cutoff(DC)   ((DC)->printer->wrapping.line_cutoff)
#define diagnostic_flush_buffer(DC)   pp_flush ((DC)->printer)
#define diagnostic_last_module_changed(DC, MAP)   ((DC)->last_module != MAP)
#define diagnostic_set_last_module(DC, MAP)   (DC)->last_module = MAP
#define diagnostic_abort_on_error(DC)   (DC)->abort_on_error = true
#define diagnostic_kind_count(DC, DK)   (DC)->diagnostic_count[(int) (DK)]
#define errorcount   diagnostic_kind_count (global_dc, DK_ERROR)
#define warningcount   diagnostic_kind_count (global_dc, DK_WARNING)
#define werrorcount   diagnostic_kind_count (global_dc, DK_WERROR)
#define sorrycount   diagnostic_kind_count (global_dc, DK_SORRY)
#define diagnostic_report_warnings_p(DC, LOC)
#define report_diagnostic(D)   diagnostic_report_diagnostic (global_dc, D)
#define diagnostic_override_column(DI, COL)   (DI)->override_column = (COL)
#define diagnostic_override_option_index(DI, OPTIDX)   ((DI)->option_index = (OPTIDX))

Typedefs

typedef struct diagnostic_info diagnostic_info
typedef struct
diagnostic_classification_change_t 
diagnostic_classification_change_t
typedef void(* diagnostic_starter_fn )(diagnostic_context *, diagnostic_info *)
typedef diagnostic_starter_fn diagnostic_finalizer_fn

Functions

static void diagnostic_inhibit_notes ()
void diagnostic_initialize (diagnostic_context *, int)
void diagnostic_finish (diagnostic_context *)
void diagnostic_report_current_module (diagnostic_context *, location_t)
void diagnostic_show_locus (diagnostic_context *, const diagnostic_info *)
diagnostic_t diagnostic_classify_diagnostic (diagnostic_context *, int, diagnostic_t, location_t)
void diagnostic_push_diagnostics (diagnostic_context *, location_t)
void diagnostic_pop_diagnostics (diagnostic_context *, location_t)
bool diagnostic_report_diagnostic (diagnostic_context *, diagnostic_info *)
void diagnostic_set_info (diagnostic_info *, const char *, va_list *, location_t, diagnostic_t) ATTRIBUTE_GCC_DIAG(2
void void diagnostic_set_info_translated (diagnostic_info *, const char *, va_list *, location_t, diagnostic_t) ATTRIBUTE_GCC_DIAG(2
void void void diagnostic_append_note (diagnostic_context *, location_t, const char *,...) ATTRIBUTE_GCC_DIAG(3
void void void char * diagnostic_build_prefix (diagnostic_context *, const diagnostic_info *)
void default_diagnostic_starter (diagnostic_context *, diagnostic_info *)
void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *)
void diagnostic_set_caret_max_width (diagnostic_context *context, int value)
char * file_name_as_prefix (diagnostic_context *, const char *)

Variables

diagnostic_contextglobal_dc

Macro Definition Documentation

#define diagnostic_abort_on_error (   DC)    (DC)->abort_on_error = true

Raise SIGABRT on any diagnostic of severity DK_ERROR or higher.

#define diagnostic_context_auxiliary_data (   DC)    (DC)->x_data

Extension hooks for client.

#define diagnostic_finalizer (   DC)    (DC)->end_diagnostic

Client supplied function called after a diagnostic message is displayed.

#define diagnostic_flush_buffer (   DC)    pp_flush ((DC)->printer)
#define diagnostic_format_decoder (   DC)    ((DC)->printer->format_decoder)

Same as pp_format_decoder. Works on 'diagnostic_context *'.

#define diagnostic_info_auxiliary_data (   DI)    (DI)->x_data
#define diagnostic_kind_count (   DC,
  DK 
)    (DC)->diagnostic_count[(int) (DK)]

The total count of a KIND of diagnostics emitted so far.

#define diagnostic_last_module_changed (   DC,
  MAP 
)    ((DC)->last_module != MAP)

True if the last module or file in which a diagnostic was reported is different from the current one.

#define diagnostic_line_cutoff (   DC)    ((DC)->printer->wrapping.line_cutoff)

Maximum characters per line in automatic line wrapping mode. Zero means don't wrap lines.

#define diagnostic_override_column (   DI,
  COL 
)    (DI)->override_column = (COL)

Override the column number to be used for reporting a diagnostic.

#define diagnostic_override_option_index (   DI,
  OPTIDX 
)    ((DI)->option_index = (OPTIDX))

Override the option index to be used for reporting a diagnostic.

#define diagnostic_prefixing_rule (   DC)    ((DC)->printer->wrapping.rule)

Same as output_prefixing_rule. Works on 'diagnostic_context *'.

#define diagnostic_report_warnings_p (   DC,
  LOC 
)
Value:
(!(DC)->dc_inhibit_warnings \
&& !(in_system_header_at (LOC) && !(DC)->dc_warn_system_headers))

Returns nonzero if warnings should be emitted.

#define diagnostic_set_last_module (   DC,
  MAP 
)    (DC)->last_module = MAP

Remember the current module or file as being the last one in which we report a diagnostic.

#define diagnostic_starter (   DC)    (DC)->begin_diagnostic

Client supplied function to announce a diagnostic.

#define errorcount   diagnostic_kind_count (global_dc, DK_ERROR)

The number of errors that have been issued so far. Ideally, these would take a diagnostic_context as an argument.

#define report_diagnostic (   D)    diagnostic_report_diagnostic (global_dc, D)
#define sorrycount   diagnostic_kind_count (global_dc, DK_SORRY)

Similarly, but for sorrys.

#define warningcount   diagnostic_kind_count (global_dc, DK_WARNING)

Similarly, but for warnings.

#define werrorcount   diagnostic_kind_count (global_dc, DK_WERROR)

Similarly, but for warnings promoted to errors.


Typedef Documentation

Each time a diagnostic's classification is changed with a pragma, we record the change and the location of the change in an array of these structs.

Various declarations for language-independent diagnostics subroutines. Copyright (C) 2000-2013 Free Software Foundation, Inc. Contributed by Gabriel Dos Reis gdr@c.nosp@m.odes.nosp@m.ource.nosp@m.ry.c.nosp@m.om

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/. A diagnostic is described by the MESSAGE to send, the FILE and LINE of its context and its KIND (ice, error, warning, note, ...) See complete list in diagnostic.def.

typedef void(* diagnostic_starter_fn)(diagnostic_context *, diagnostic_info *)

Forward declarations.


Function Documentation

void void void diagnostic_append_note ( diagnostic_context ,
location_t  ,
const char *  ,
  ... 
)
void void void 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.

Copyright (C) 2001-2013 Free Software Foundation, Inc.

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/.

DK_UNSPECIFIED must be first so it has a value of zero. We never assign this kind to an actual diagnostic, we only use this in variables that can hold a kind, to mean they have yet to have a kind specified. I.e. they're uninitialized. Within the diagnostic machinery, this kind also means "don't change the existing kind", meaning "no change is specified".

If a diagnostic is set to DK_IGNORED, it won't get reported at all. This is used by the diagnostic machinery when it wants to disable a diagnostic without disabling the option which causes it.

The remainder are real diagnostic types.

These two would be re-classified as DK_WARNING or DK_ERROR, so the prefix does not matter.

This one is just for counting DK_WARNING promoted to DK_ERROR due to -Werror and -Werror=warning.

Copyright (C) 2001-2013 Free Software Foundation, Inc.

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/.

DK_UNSPECIFIED must be first so it has a value of zero. We never assign this kind to an actual diagnostic, we only use this in variables that can hold a kind, to mean they have yet to have a kind specified. I.e. they're uninitialized. Within the diagnostic machinery, this kind also means "don't change the existing kind", meaning "no change is specified".

If a diagnostic is set to DK_IGNORED, it won't get reported at all. This is used by the diagnostic machinery when it wants to disable a diagnostic without disabling the option which causes it.

The remainder are real diagnostic types.

These two would be re-classified as DK_WARNING or DK_ERROR, so the prefix does not matter.

This one is just for counting DK_WARNING promoted to DK_ERROR due to -Werror and -Werror=warning.

References colorize_start(), colorize_stop(), diagnostic_info::kind, and pp_show_color.

Referenced by default_tree_diagnostic_starter(), and trim_filename().

diagnostic_t diagnostic_classify_diagnostic ( diagnostic_context context,
int  option_index,
diagnostic_t  new_kind,
location_t  where 
)

Force diagnostics controlled by OPTIDX to be kind KIND.

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.

Handle pragmas separately, since we need to keep track of where the pragmas were.

void diagnostic_finish ( diagnostic_context )
static void diagnostic_inhibit_notes ( )
inlinestatic
void diagnostic_initialize ( diagnostic_context ,
int   
)

Diagnostic related functions.

void diagnostic_pop_diagnostics ( diagnostic_context ,
location_t   
)
void diagnostic_push_diagnostics ( diagnostic_context ,
location_t   
)
void diagnostic_report_current_module ( diagnostic_context ,
location_t   
)
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.

 Give preference to being able to inhibit warnings, before they
 get reclassified to something else.   
     We do this to avoid giving the message for -pedantic-errors.   
     If we're reporting an ICE in the middle of some other error,
     try to flush out the previous error, then let this one
     through.  Don't do this more than once.   
 If the user requested that warnings be treated as errors, so be
 it.  Note that we do this before the next block so that
 individual warnings can be overridden back to warnings with
 -Wno-error=*.   
     This tests if the user provided the appropriate -Wfoo or
     -Wno-foo option.   
     This tests for #pragma diagnostic changes.   
         FIXME: Stupid search.  Optimize later.  
                 The option 0 is for all the diagnostics.   
     This tests if the user provided the appropriate -Werror=foo
     option.   
     This allows for future extensions, like temporarily disabling
     warnings for ranges of source code.   
     When not checking, ICEs are converted to fatal errors when an
     error has already occurred.  This is counteracted by
     abort_on_error.   

References diagnostic_info::kind.

void diagnostic_set_caret_max_width ( diagnostic_context context,
int  value 
)
void diagnostic_set_info ( diagnostic_info ,
const char *  ,
va_list *  ,
location_t  ,
diagnostic_t   
)
void void diagnostic_set_info_translated ( diagnostic_info ,
const char *  ,
va_list *  ,
location_t  ,
diagnostic_t   
)
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.

pp_printf does not implement %*c.

Referenced by trim_filename().

char* file_name_as_prefix ( diagnostic_context ,
const char *   
)

Pure text formatting support functions.


Variable Documentation

diagnostic_context* global_dc

This diagnostic_context is used by front-ends that directly output diagnostic messages without going through `error', `warning', and similar functions.

Referenced by display_help(), get_src_pwd(), main(), and verbatim().