diff options
-rw-r--r-- | gcc/ChangeLog | 43 | ||||
-rw-r--r-- | gcc/diagnostic.c | 209 | ||||
-rw-r--r-- | gcc/diagnostic.h | 2 | ||||
-rw-r--r-- | gcc/f/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/f/bad.c | 5 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 9 |
6 files changed, 175 insertions, 99 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 38c5bfb..3b61253 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,36 @@ +2003-05-12 Zack Weinberg <zack@codesourcery.com> + + * diagnostic.c (diagnostic_for_decl): Take a + diagnostic_context argument. Restructure to be consistent + with diagnostic_report_diagnostic. + (diagnostic_count_diagnostic): Now static. Take a + diagnostic_info argument, not just a diagnostic_t. Some code + moved here from internal_error. Move a case label for + clarity. + (diagnostic_action_after_output): New function. Code moved + here from internal_error and fatal_error. + (bug_report_request): New #define so that this text appears in + only one place. + (diagnostic_report_diagnostic): Update to match changes to + diagnostic_count_diagnostic. Call diagnostic_action_after_output. + (diagnostic_set_info): Call gettext here. + + (pedwarn): Update comment. Don't call gettext here. + (sorry): Use report_diagnostic. Don't call gettext here. + (fatal_error): Remove final fnotice and exit, but call + real_abort to prevent warnings about noreturn function returning. + (internal_error): Likewise. Don't do ICE suppression here nor + call context->internal_error. + (warning_with_decl): Suppress for decls in system headers. + Adjust call to diagnostic_for_decl. + (pedwarn_with_decl): Likewise. + (error_with_decl): Adjust call to diagnostic_for_decl. + (error_recursion): Use bug_report_request. + + * diagnostic.h: Remove prototype of diagnostic_count_diagnostic. + * objc/objc-act.c (error_with_ivar, warn_with_method): Don't call + diagnostic_count_diagnostic. + 2003-05-12 John David Anglin <dave.anglin@nrc-cnrc.gc.ca> * pa64-hpux.h (ASM_OUTPUT_ALIGNED_COMMON): Correct last patch. @@ -107,7 +140,7 @@ Mon May 12 11:32:53 CEST 2003 Jan Hubicka <jh@suse.cz> asm_emit_uninitialized, assemble_zeros, assemble_static_space): HOST_WIDE_INT argument -2003-05-10 Steven Bosscher <steven@gcc.gnu.org> +2003-05-10 Steven Bosscher <steven@gcc.gnu.org> * cgraphunit.c (cgraph_create_edges): Drop walk_tree in favor of walk_tree_without_duplicates. Add comments. @@ -115,7 +148,7 @@ Mon May 12 11:32:53 CEST 2003 Jan Hubicka <jh@suse.cz> 2003-05-12 Josef Zlomek <zlomekj@suse.cz> * alloc-pool.h (ALLOC_POOL_ID_TYPE): New type. - (struct alloc_pool_def): New element 'id'. + (struct alloc_pool_def): New element 'id'. * alloc-pool.c (fancy_abort): Extern function prototype. (abort): Macro which uses fancy_abort. (struct allocation_object_def): New structure. @@ -140,7 +173,7 @@ Mon May 12 11:32:53 CEST 2003 Jan Hubicka <jh@suse.cz> components, components_notype): Build list in reverse order. (enumlist): Clarify docs. Use TREE_CHAIN not chainon. - * tree.c (chainon): Special case op2 null as well. + * tree.c (chainon): Special case op2 null as well. Reorg for clarity. 2003-05-11 Roger Sayle <roger@eyesopen.com> @@ -156,7 +189,7 @@ Mon May 12 11:32:53 CEST 2003 Jan Hubicka <jh@suse.cz> 2003-05-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> - * Makefile.in (out_object_file): Don't set -Wno-error for ${cpu}.o. + * Makefile.in (out_object_file): Don't set -Wno-error for ${cpu}.o. * sparc.c (print_operand): Fix uninitialized warning. @@ -214,7 +247,7 @@ Mon May 12 11:32:53 CEST 2003 Jan Hubicka <jh@suse.cz> * varasm.c (copy_constant, case VIEW_CONVERT_EXPR): New case. 2003-05-11 Bruno Haible <bruno@clisp.org> - + * cppfiles.c (find_or_create_entry): Preserve errno. 2003-05-11 Neil Booth <neil@cat.daikokuya.co.uk> diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index ce6c8bc..92e749f 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -54,7 +54,8 @@ static void output_indent PARAMS ((output_buffer *)); static char *build_message_string PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; static void format_with_decl PARAMS ((output_buffer *, text_info *, tree)); -static void diagnostic_for_decl PARAMS ((diagnostic_info *, tree)); +static void diagnostic_for_decl PARAMS ((diagnostic_context *, + diagnostic_info *, tree)); static void set_real_maximum_length PARAMS ((output_buffer *)); static void output_unsigned_decimal PARAMS ((output_buffer *, unsigned int)); @@ -79,6 +80,10 @@ static void default_diagnostic_finalizer PARAMS ((diagnostic_context *, static void error_recursion PARAMS ((diagnostic_context *)) ATTRIBUTE_NORETURN; static bool text_specifies_location PARAMS ((text_info *, location_t *)); +static bool diagnostic_count_diagnostic PARAMS ((diagnostic_context *, + diagnostic_info *)); +static void diagnostic_action_after_output PARAMS ((diagnostic_context *, + diagnostic_info *)); static void real_abort PARAMS ((void)) ATTRIBUTE_NORETURN; extern int rtl_dump_and_exit; @@ -88,6 +93,12 @@ extern int warnings_are_errors; static diagnostic_context global_diagnostic_context; diagnostic_context *global_dc = &global_diagnostic_context; +/* Boilerplate text used in two locations. */ +#define bug_report_request \ +"Please submit a full bug report,\n\ +with preprocessed source if appropriate.\n\ +See %s for instructions.\n" + /* Subroutine of output_set_maximum_length. Set up BUFFER's internal maximum characters per line. */ @@ -805,7 +816,7 @@ diagnostic_set_info (diagnostic, msgid, args, file, line, kind) int line; diagnostic_t kind; { - diagnostic->message.format_spec = msgid; + diagnostic->message.format_spec = _(msgid); diagnostic->message.args_ptr = args; /* If the diagnostic message doesn't specify a location, use FILE and LINE. */ @@ -850,18 +861,38 @@ diagnostic_flush_buffer (context) } /* Count a diagnostic. Return true if the message should be printed. */ -bool -diagnostic_count_diagnostic (context, kind) +static bool +diagnostic_count_diagnostic (context, diagnostic) diagnostic_context *context; - diagnostic_t kind; + diagnostic_info *diagnostic; { + diagnostic_t kind = diagnostic->kind; switch (kind) { default: abort(); break; - case DK_FATAL: case DK_ICE: case DK_SORRY: + case DK_ICE: +#ifndef ENABLE_CHECKING + /* When not checking, ICEs are converted to fatal errors when an + error has already occurred. This is counteracted by + abort_on_error. */ + if ((diagnostic_kind_count (context, DK_ERROR) > 0 + || diagnostic_kind_count (context, DK_SORRY) > 0) + && !context->abort_on_error) + { + fnotice (stderr, "%s:%d: confused by earlier errors, bailing out\n", + diagnostic->location.file, diagnostic->location.line); + exit (FATAL_EXIT_CODE); + } +#endif + if (context->internal_error) + (*context->internal_error) (diagnostic->message.format_spec, + diagnostic->message.args_ptr); + /* fall through */ + + case DK_FATAL: case DK_SORRY: case DK_ANACHRONISM: case DK_NOTE: ++diagnostic_kind_count (context, kind); break; @@ -869,20 +900,22 @@ diagnostic_count_diagnostic (context, kind) case DK_WARNING: if (!diagnostic_report_warnings_p ()) return false; - else if (!warnings_are_errors) + + 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) + if (context->warnings_are_errors_message) { output_verbatim (&context->buffer, "%s: warnings being treated as errors\n", progname); context->warnings_are_errors_message = false; } + + /* and fall through */ + case DK_ERROR: ++diagnostic_kind_count (context, DK_ERROR); break; } @@ -890,6 +923,46 @@ diagnostic_count_diagnostic (context, kind) return true; } +/* Take any action which is expected to happen after the diagnostic + is written out. This function does not always return. */ +static void +diagnostic_action_after_output (context, diagnostic) + diagnostic_context *context; + diagnostic_info *diagnostic; +{ + switch (diagnostic->kind) + { + case DK_DEBUG: + case DK_NOTE: + case DK_ANACHRONISM: + case DK_WARNING: + break; + + case DK_ERROR: + case DK_SORRY: + if (context->abort_on_error) + real_abort (); + break; + + case DK_ICE: + if (context->abort_on_error) + real_abort (); + + fnotice (stderr, bug_report_request, bug_report_url); + exit (FATAL_EXIT_CODE); + + case DK_FATAL: + if (context->abort_on_error) + real_abort (); + + fnotice (stderr, "compilation terminated.\n"); + exit (FATAL_EXIT_CODE); + + default: + real_abort (); + } +} + /* Called when the start of a function definition is parsed, this function prints on stderr the name of the function. */ void @@ -1016,40 +1089,40 @@ diagnostic_report_diagnostic (context, diagnostic) if (context->lock++) error_recursion (context); - if (diagnostic_count_diagnostic (context, diagnostic->kind)) + if (diagnostic_count_diagnostic (context, diagnostic)) { (*diagnostic_starter (context)) (context, diagnostic); output_format (&context->buffer, &diagnostic->message); (*diagnostic_finalizer (context)) (context, diagnostic); output_flush (&context->buffer); + diagnostic_action_after_output (context, diagnostic); } - if (context->abort_on_error && diagnostic->kind <= DK_ERROR) - real_abort(); - --context->lock; + context->lock--; } /* Report a diagnostic MESSAGE at the declaration DECL. MSG is a format string which uses %s to substitute the declaration name; subsequent substitutions are a la output_format. */ static void -diagnostic_for_decl (diagnostic, decl) +diagnostic_for_decl (context, diagnostic, decl) + diagnostic_context *context; diagnostic_info *diagnostic; tree decl; { - if (global_dc->lock++) - error_recursion (global_dc); + if (context->lock++) + error_recursion (context); - if (diagnostic_count_diagnostic (global_dc, diagnostic->kind)) + if (diagnostic_count_diagnostic (context, diagnostic)) { - diagnostic_report_current_function (global_dc); - output_set_prefix - (&global_dc->buffer, diagnostic_build_prefix (diagnostic)); - format_with_decl (&global_dc->buffer, &diagnostic->message, decl); - output_flush (&global_dc->buffer); - output_destroy_prefix (&global_dc->buffer); + (*diagnostic_starter (context)) (context, diagnostic); + format_with_decl (&context->buffer, &diagnostic->message, decl); + (*diagnostic_finalizer (context)) (context, diagnostic); + output_flush (&context->buffer); + diagnostic_action_after_output (context, diagnostic); } - global_dc->lock--; + + context->lock--; } /* Given a partial pathname as input, return another pathname that @@ -1148,15 +1221,14 @@ warning VPARAMS ((const char *msgid, ...)) VA_CLOSE (ap); } -/* A "pedantic" warning. Use this for code which triggers a - diagnostic which is required by the relevant language - specification, but which is considered unhelpful (i.e. there isn't - anything *really* wrong with the construct in the language as she - is spoke). It is a normal warning unless -pedantic-errors is - applied, which turns it into an error. Note that pedwarn-s still - happen if -pedantic is not given; you must write - "if (pedantic) pedwarn (...)" to get a warning enabled only under - -pedantic. All such warnings should, however, use pedwarn. */ +/* A "pedantic" warning: 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 -pedantic command-line switch. To get a warning enabled + only with that switch, write "if (pedantic) pedwarn (...);" */ void pedwarn VPARAMS ((const char *msgid, ...)) { @@ -1164,7 +1236,7 @@ pedwarn VPARAMS ((const char *msgid, ...)) VA_OPEN (ap, msgid); VA_FIXEDARG (ap, const char *, msgid); - diagnostic_set_info (&diagnostic, _(msgid), &ap, input_filename, input_line, + diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, pedantic_error_kind ()); report_diagnostic (&diagnostic); VA_CLOSE (ap); @@ -1197,14 +1269,9 @@ sorry VPARAMS ((const char *msgid, ...)) VA_OPEN (ap, msgid); VA_FIXEDARG (ap, const char *, msgid); - ++sorrycount; - diagnostic_set_info (&diagnostic, _(msgid), &ap, - input_filename, input_line, DK_SORRY); - - output_set_prefix - (&global_dc->buffer, diagnostic_build_prefix (&diagnostic)); - output_format (&global_dc->buffer, &diagnostic.message); - output_flush (&global_dc->buffer); + diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, + DK_SORRY); + report_diagnostic (&diagnostic); VA_CLOSE (ap); } @@ -1224,8 +1291,8 @@ fatal_error VPARAMS ((const char *msgid, ...)) report_diagnostic (&diagnostic); VA_CLOSE (ap); - fnotice (stderr, "compilation terminated.\n"); - exit (FATAL_EXIT_CODE); + /* NOTREACHED */ + real_abort (); } /* An internal consistency check has failed. We make no attempt to @@ -1240,31 +1307,13 @@ internal_error VPARAMS ((const char *msgid, ...)) VA_OPEN (ap, msgid); VA_FIXEDARG (ap, const char *, msgid); - if (global_dc->lock) - error_recursion (global_dc); - -#ifndef ENABLE_CHECKING - if (errorcount > 0 || sorrycount > 0) - { - fnotice (stderr, "%s:%d: confused by earlier errors, bailing out\n", - input_filename, input_line); - exit (FATAL_EXIT_CODE); - } -#endif - - if (global_dc->internal_error != 0) - (*global_dc->internal_error) (_(msgid), &ap); - diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, input_line, DK_ICE); report_diagnostic (&diagnostic); VA_CLOSE (ap); - fnotice (stderr, -"Please submit a full bug report,\n\ -with preprocessed source if appropriate.\n\ -See %s for instructions.\n", bug_report_url); - exit (FATAL_EXIT_CODE); + /* NOTREACHED */ + real_abort (); } /* Variants of some of the above, which make reference to a particular @@ -1278,10 +1327,15 @@ warning_with_decl VPARAMS ((tree decl, const char *msgid, ...)) VA_FIXEDARG (ap, tree, decl); VA_FIXEDARG (ap, const char *, msgid); + /* Do not issue a warning about a decl which came from a system header, + unless -Wsystem-headers. */ + if (DECL_IN_SYSTEM_HEADER (decl) && !warn_system_headers) + return; + diagnostic_set_info (&diagnostic, msgid, &ap, DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), DK_WARNING); - diagnostic_for_decl (&diagnostic, decl); + diagnostic_for_decl (global_dc, &diagnostic, decl); VA_CLOSE (ap); } @@ -1293,18 +1347,16 @@ pedwarn_with_decl VPARAMS ((tree decl, const char *msgid, ...)) VA_FIXEDARG (ap, tree, decl); VA_FIXEDARG (ap, const char *, msgid); - diagnostic_set_info (&diagnostic, _(msgid), &ap, + /* Do not issue a warning about a decl which came from a system header, + unless -Wsystem-headers. */ + if (DECL_IN_SYSTEM_HEADER (decl) && !warn_system_headers) + return; + + diagnostic_set_info (&diagnostic, msgid, &ap, DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), pedantic_error_kind ()); + diagnostic_for_decl (global_dc, &diagnostic, decl); - /* We don't want -pedantic-errors to cause the compilation to fail from - "errors" in system header files. Sometimes fixincludes can't fix what's - broken (eg: unsigned char bitfields - fixing it may change the alignment - which will cause programs to mysteriously fail because the C library - or kernel uses the original layout). There's no point in issuing a - warning either, it's just unnecessary noise. */ - if (!DECL_IN_SYSTEM_HEADER (decl)) - diagnostic_for_decl (&diagnostic, decl); VA_CLOSE (ap); } @@ -1319,7 +1371,7 @@ error_with_decl VPARAMS ((tree decl, const char *msgid, ...)) diagnostic_set_info (&diagnostic, msgid, &ap, DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), DK_ERROR); - diagnostic_for_decl (&diagnostic, decl); + diagnostic_for_decl (global_dc, &diagnostic, decl); VA_CLOSE (ap); } @@ -1410,10 +1462,7 @@ error_recursion (context) fnotice (stderr, "Internal compiler error: Error reporting routines re-entered.\n"); - fnotice (stderr, -"Please submit a full bug report,\n\ -with preprocessed source if appropriate.\n\ -See %s for instructions.\n", bug_report_url); + fnotice (stderr, bug_report_request, bug_report_url); exit (FATAL_EXIT_CODE); } diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 3f12a91..1d697f4 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -294,8 +294,6 @@ extern void diagnostic_initialize PARAMS ((diagnostic_context *)); 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 *)); extern void diagnostic_set_info PARAMS ((diagnostic_info *, diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index a57818ff..94d1eb1 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,3 +1,7 @@ +2003-05-12 Zack Weinberg <zack@codesourcery.com> + + * bad.c: Don't call diagnostic_count_diagnostic. + 2003-05-12 Roger Sayle <roger@eyesopen.com> * com.c (ffecom_init_0): Define built-in functions for atan2, @@ -78,7 +82,7 @@ * lex.c (ffelex_file_pop_): Rename parameter from input_filename. (ffelex_file_push_): Likewise. - + * ste.c (struct gbe_block): Rename field from input_filename. (ffeste_start_block_, ffeste_start_stmt_): Likewise. diff --git a/gcc/f/bad.c b/gcc/f/bad.c index 21fa487..deed124 100644 --- a/gcc/f/bad.c +++ b/gcc/f/bad.c @@ -203,11 +203,12 @@ ffebad_start_ (bool lex_override, ffebad errnum, ffebadSeverity sev, if ((ffebad_severity_ != FFEBAD_severityPEDANTIC) || !flag_pedantic_errors) { - if (!diagnostic_count_diagnostic (global_dc, DK_WARNING)) + if (!diagnostic_report_warnings_p ()) { /* User wants no warnings. */ ffebad_is_temp_inhibited_ = TRUE; return FALSE; } + diagnostic_kind_count (global_dc, DK_WARNING)++; break; } /* Fall through (PEDANTIC && flag_pedantic_errors). */ @@ -215,7 +216,7 @@ ffebad_start_ (bool lex_override, ffebad errnum, ffebadSeverity sev, case FFEBAD_severityWEIRD: case FFEBAD_severitySEVERE: case FFEBAD_severityDISASTER: - diagnostic_count_diagnostic (global_dc, DK_ERROR); + diagnostic_kind_count (global_dc, DK_ERROR)++; break; default: diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 5cb7c1d..dd6b87e 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -3539,10 +3539,6 @@ error_with_ivar (message, decl, rawdecl) tree decl; tree rawdecl; { - diagnostic_count_diagnostic (global_dc, DK_ERROR); - - diagnostic_report_current_function (global_dc); - error ("%H%s `%s'", &DECL_SOURCE_LOCATION (decl), message, gen_declaration (rawdecl, errbuf)); @@ -7108,11 +7104,6 @@ warn_with_method (message, mtype, method) int mtype; tree method; { - if (!diagnostic_count_diagnostic (global_dc, DK_WARNING)) - return; - - diagnostic_report_current_function (global_dc); - /* Add a readable method name to the warning. */ warning ("%H%s `%c%s'", &DECL_SOURCE_LOCATION (method), message, mtype, gen_method_decl (method, errbuf)); |