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