diagnostic.[ch]: Rename diagnostic_count_error
Gabriel Dos Reis
gdr@codesourcery.com
Tue Jun 11 16:14:00 GMT 2002
Now that we have different kinds of diagnostic, this patch renames
diagnostic_count_error to diagnostic_count_diagnostic to match
semantics.
Boostrapped and tested on an i686-pc-linux
-- Gaby
2002-06-12 Gabriel Dos Reis <gdr@codesourcery.com>
* objc/objc-act.c (warn_with_ivar): Adjust calls to
diagnostic_count_error.
(warn_with_method): Likewise.
* diagnostic.h (warnings_are_errors_message): New field of
diagnostic_context.
(diagnostic_count_error): Rename to diagnostic_count_diagnostic to
match semantics.
* diagnostic.c: Adjust calls to diagnostic_count_error through out.
(diagnostic_count_diagnostic): Make aware of other kinds of
diagnostics.
(diagnostic_initialize): Initialize warnings_are_errors_message field.
f/
2002-06-12 Gabriel Dos Reis <gdr@codesourcery.com>
* bad.c (ffebad_start_): Adjust calls to diagnostic_count_error.
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.c,v
retrieving revision 1.88
diff -p -r1.88 diagnostic.c
*** diagnostic.c 7 Jun 2002 16:35:52 -0000 1.88
--- diagnostic.c 11 Jun 2002 23:06:04 -0000
*************** diagnostic_initialize (context)
*** 766,771 ****
--- 766,772 ----
diagnostic_starter (context) = default_diagnostic_starter;
diagnostic_finalizer (context) = default_diagnostic_finalizer;
+ context->warnings_are_errors_message = warnings_are_errors;
}
void
*************** diagnostic_for_decl (diagnostic, decl)
*** 819,825 ****
if (global_dc->lock++)
error_recursion (global_dc);
! if (diagnostic_count_error (global_dc, diagnostic->kind))
{
diagnostic_report_current_function (global_dc);
output_set_prefix
--- 820,826 ----
if (global_dc->lock++)
error_recursion (global_dc);
! if (diagnostic_count_diagnostic (global_dc, diagnostic->kind))
{
diagnostic_report_current_function (global_dc);
output_set_prefix
*************** diagnostic_flush_buffer (context)
*** 839,867 ****
fflush (output_buffer_attached_stream (&context->buffer));
}
! /* Count an error or warning. Return true if the message should be
! printed. */
bool
! diagnostic_count_error (context, kind)
diagnostic_context *context;
diagnostic_t kind;
{
! if (kind == DK_WARNING && !diagnostic_report_warnings_p ())
! return false;
!
! if (kind == DK_WARNING && !warnings_are_errors)
! ++diagnostic_kind_count (context, DK_WARNING);
! else
{
! static bool warning_message = false;
!
! if (kind == DK_WARNING && !warning_message)
! {
output_verbatim (&context->buffer,
"%s: warnings being treated as errors\n", progname);
! warning_message = true;
! }
++diagnostic_kind_count (context, DK_ERROR);
}
return true;
--- 840,881 ----
fflush (output_buffer_attached_stream (&context->buffer));
}
! /* Count a diagnostic. Return true if the message should be printed. */
bool
! diagnostic_count_diagnostic (context, kind)
diagnostic_context *context;
diagnostic_t kind;
{
! switch (kind)
{
! default:
! abort();
! break;
!
! case DK_FATAL: case DK_ICE: case DK_SORRY:
! case DK_ANACHRONISM: case DK_NOTE:
! ++diagnostic_kind_count (context, kind);
! break;
!
! case DK_WARNING:
! if (!diagnostic_report_warnings_p ())
! return false;
! else if (!warnings_are_errors)
! {
! ++diagnostic_kind_count (context, DK_WARNING);
! break;
! }
! /* else fall through. */
!
! case DK_ERROR:
! if (kind == DK_WARNING && context->warnings_are_errors_message)
! {
output_verbatim (&context->buffer,
"%s: warnings being treated as errors\n", progname);
! context->warnings_are_errors_message = false;
! }
++diagnostic_kind_count (context, DK_ERROR);
+ break;
}
return true;
*************** diagnostic_report_diagnostic (context, d
*** 1220,1226 ****
if (context->lock++)
error_recursion (context);
! if (diagnostic_count_error (context, diagnostic->kind))
{
(*diagnostic_starter (context)) (context, diagnostic);
output_format (&context->buffer, &diagnostic->message);
--- 1234,1240 ----
if (context->lock++)
error_recursion (context);
! if (diagnostic_count_diagnostic (context, diagnostic->kind))
{
(*diagnostic_starter (context)) (context, diagnostic);
output_format (&context->buffer, &diagnostic->message);
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.h,v
retrieving revision 1.43
diff -p -r1.43 diagnostic.h
*** diagnostic.h 5 Jun 2002 19:35:32 -0000 1.43
--- diagnostic.h 11 Jun 2002 23:06:04 -0000
*************** struct diagnostic_context
*** 187,192 ****
--- 187,196 ----
/* The number of times we have issued diagnostics. */
int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND];
+ /* True if we should display the "warnings are being tread as error"
+ message, usually displayed once per compiler run. */
+ bool warnings_are_errors_message;
+
/* This function is called before any message is printed out. It is
responsible for preparing message prefix and such. For example, it
might say:
*************** extern void diagnostic_initialize PARAMS
*** 284,290 ****
extern void diagnostic_report_current_module PARAMS ((diagnostic_context *));
extern void diagnostic_report_current_function PARAMS ((diagnostic_context *));
extern void diagnostic_flush_buffer PARAMS ((diagnostic_context *));
! extern bool diagnostic_count_error PARAMS ((diagnostic_context *,
diagnostic_t));
extern void diagnostic_report_diagnostic PARAMS ((diagnostic_context *,
diagnostic_info *));
--- 288,294 ----
extern void diagnostic_report_current_module PARAMS ((diagnostic_context *));
extern void diagnostic_report_current_function PARAMS ((diagnostic_context *));
extern void diagnostic_flush_buffer PARAMS ((diagnostic_context *));
! extern bool diagnostic_count_diagnostic PARAMS ((diagnostic_context *,
diagnostic_t));
extern void diagnostic_report_diagnostic PARAMS ((diagnostic_context *,
diagnostic_info *));
Index: f/bad.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/f/bad.c,v
retrieving revision 1.18
diff -p -r1.18 bad.c
*** f/bad.c 5 Jun 2002 19:35:45 -0000 1.18
--- f/bad.c 11 Jun 2002 23:06:07 -0000
*************** ffebad_start_ (bool lex_override, ffebad
*** 203,209 ****
if ((ffebad_severity_ != FFEBAD_severityPEDANTIC)
|| !flag_pedantic_errors)
{
! if (!diagnostic_count_error (global_dc, DK_WARNING))
{ /* User wants no warnings. */
ffebad_is_temp_inhibited_ = TRUE;
return FALSE;
--- 203,209 ----
if ((ffebad_severity_ != FFEBAD_severityPEDANTIC)
|| !flag_pedantic_errors)
{
! if (!diagnostic_count_diagnostic (global_dc, DK_WARNING))
{ /* User wants no warnings. */
ffebad_is_temp_inhibited_ = TRUE;
return FALSE;
*************** ffebad_start_ (bool lex_override, ffebad
*** 215,221 ****
case FFEBAD_severityWEIRD:
case FFEBAD_severitySEVERE:
case FFEBAD_severityDISASTER:
! diagnostic_count_error (global_dc, DK_ERROR);
break;
default:
--- 215,221 ----
case FFEBAD_severityWEIRD:
case FFEBAD_severitySEVERE:
case FFEBAD_severityDISASTER:
! diagnostic_count_diagnostic (global_dc, DK_ERROR);
break;
default:
Index: objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/objc/objc-act.c,v
retrieving revision 1.136
diff -p -r1.136 objc-act.c
*** objc/objc-act.c 5 Jun 2002 19:35:45 -0000 1.136
--- objc/objc-act.c 11 Jun 2002 23:06:10 -0000
*************** error_with_ivar (message, decl, rawdecl)
*** 3416,3422 ****
tree decl;
tree rawdecl;
{
! diagnostic_count_error (global_dc, DK_ERROR);
diagnostic_report_current_function (global_dc);
--- 3416,3422 ----
tree decl;
tree rawdecl;
{
! diagnostic_count_diagnostic (global_dc, DK_ERROR);
diagnostic_report_current_function (global_dc);
*************** warn_with_method (message, mtype, method
*** 6895,6901 ****
int mtype;
tree method;
{
! if (!diagnostic_count_error (global_dc, DK_WARNING))
return;
diagnostic_report_current_function (global_dc);
--- 6895,6901 ----
int mtype;
tree method;
{
! if (!diagnostic_count_diagnostic (global_dc, DK_WARNING))
return;
diagnostic_report_current_function (global_dc);
More information about the Gcc-patches
mailing list