00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GCC_DIAGNOSTIC_H
00023 #define GCC_DIAGNOSTIC_H
00024
00025 #include "pretty-print.h"
00026
00027
00028 typedef enum
00029 {
00030 #define DEFINE_DIAGNOSTIC_KIND(K, msgid) K,
00031 #include "diagnostic.def"
00032 #undef DEFINE_DIAGNOSTIC_KIND
00033 DK_LAST_DIAGNOSTIC_KIND
00034 } diagnostic_t;
00035
00036
00037
00038
00039 typedef struct
00040 {
00041 text_info message;
00042 location_t location;
00043
00044 diagnostic_t kind;
00045 } diagnostic_info;
00046
00047 #define pedantic_error_kind() (flag_pedantic_errors ? DK_ERROR : DK_WARNING)
00048
00049
00050
00051 typedef struct diagnostic_context diagnostic_context;
00052 typedef void (*diagnostic_starter_fn) (diagnostic_context *,
00053 diagnostic_info *);
00054 typedef diagnostic_starter_fn diagnostic_finalizer_fn;
00055
00056
00057
00058 struct diagnostic_context
00059 {
00060
00061 pretty_printer *printer;
00062
00063
00064 int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND];
00065
00066
00067
00068 bool issue_warnings_are_errors_message;
00069
00070
00071 bool warning_as_error_requested;
00072
00073
00074 bool abort_on_error;
00075
00076
00077
00078
00079
00080
00081
00082
00083 diagnostic_starter_fn begin_diagnostic;
00084
00085
00086 diagnostic_finalizer_fn end_diagnostic;
00087
00088
00089 void (*internal_error) (const char *, va_list *);
00090
00091
00092
00093
00094 tree last_function;
00095
00096
00097 int last_module;
00098
00099 int lock;
00100 };
00101
00102
00103 #define diagnostic_starter(DC) (DC)->begin_diagnostic
00104
00105
00106
00107 #define diagnostic_finalizer(DC) (DC)->end_diagnostic
00108
00109
00110 #define diagnostic_auxiliary_data(DC) (DC)->x_data
00111
00112
00113 #define diagnostic_format_decoder(DC) ((DC)->printer->format_decoder)
00114
00115
00116 #define diagnostic_prefixing_rule(DC) ((DC)->printer->prefixing_rule)
00117
00118
00119
00120 #define diagnostic_line_cutoff(DC) ((DC)->printer->ideal_maximum_length)
00121
00122 #define diagnostic_flush_buffer(DC) pp_base_flush ((DC)->printer)
00123
00124
00125
00126 #define diagnostic_last_function_changed(DC) \
00127 ((DC)->last_function != current_function_decl)
00128
00129
00130
00131 #define diagnostic_set_last_function(DC) \
00132 (DC)->last_function = current_function_decl
00133
00134
00135
00136 #define diagnostic_last_module_changed(DC) \
00137 ((DC)->last_module != input_file_stack_tick)
00138
00139
00140
00141 #define diagnostic_set_last_module(DC) \
00142 (DC)->last_module = input_file_stack_tick
00143
00144
00145 #define diagnostic_abort_on_error(DC) \
00146 (DC)->abort_on_error = true
00147
00148
00149
00150
00151 extern diagnostic_context *global_dc;
00152
00153
00154 #define diagnostic_kind_count(DC, DK) (DC)->diagnostic_count[(int) (DK)]
00155
00156
00157
00158 #define errorcount diagnostic_kind_count (global_dc, DK_ERROR)
00159
00160 #define warningcount diagnostic_kind_count (global_dc, DK_WARNING)
00161
00162 #define sorrycount diagnostic_kind_count (global_dc, DK_SORRY)
00163
00164
00165 #define diagnostic_report_warnings_p() \
00166 (!inhibit_warnings \
00167 && !(in_system_header && !warn_system_headers))
00168
00169 #define report_diagnostic(D) diagnostic_report_diagnostic (global_dc, D)
00170
00171
00172 extern void diagnostic_initialize (diagnostic_context *);
00173 extern void diagnostic_report_current_module (diagnostic_context *);
00174 extern void diagnostic_report_current_function (diagnostic_context *);
00175 extern void diagnostic_report_diagnostic (diagnostic_context *,
00176 diagnostic_info *);
00177 extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
00178 location_t, diagnostic_t);
00179 extern char *diagnostic_build_prefix (diagnostic_info *);
00180
00181
00182 extern void verbatim (const char *, ...);
00183 extern char *file_name_as_prefix (const char *);
00184
00185 extern void debug_output_buffer (pretty_printer *);
00186
00187
00188 extern int dump_generic_node (pretty_printer *, tree, int, int, bool);
00189 extern void print_generic_stmt (FILE *, tree, int);
00190 extern void print_generic_stmt_indented (FILE *, tree, int, int);
00191 extern void print_generic_expr (FILE *, tree, int);
00192 extern void print_generic_decl (FILE *, tree, int);
00193
00194 extern void debug_generic_expr (tree);
00195 extern void debug_generic_stmt (tree);
00196 extern void debug_c_tree (tree);
00197 #endif