From b6fe0bb8c5a68ed64a124734c3fdc39777f8f7e6 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Fri, 25 Jul 2003 09:52:32 +0000 Subject: Remove pedwarn_with_decl, warning_with_decl and error_with_decl from GCC. Remove pedwarn_with_decl, warning_with_decl and error_with_decl from GCC. * calls.c (try_to_integrate): Don't use xxx_with_decl. (expand_call): Likewise. * dwarfout.c (output_reg_number): Likewise. * expr.c (expand_expr): Likewise. * function.c (assign_temp): Likewise. (uninitialized_vars_warning): Likewise. (setjmp_args_warning): Likewise. (expand_function_end): Likewise. * stmt.c (fixup_gotos): Likewise. (warn_about_unused_variables): Likewise. (expand_end_bindings): Likewise. * stor-layout.c (layout_decl): Likewise. (place_field): Likewise. * toplev.c (check_global_declarations): Likewise. (rest_of_handle_inlining): Likewise. (default_tree_printer): New function. (general_init): Initialize diagnostic machinery before routing signals to the ICE machinery. Set default tree printer. * toplev.h (pedwarn_with_decl): Remove declaration. (warning_with_decl): Likewise. (error_with_decl): Likewise. (pedwarn): Remove attribute for the time being. * tree-inline.c (expand_call_inline): Don't use xxx_with_decl. * varasm.c (named_section): Likewise. (make_decl_rtl): Likewise. (assemble_variable): Likewise. (merge_weak): Likewise. (declare_weak): Likewise. * diagnostic.h: Move non-diagnostic stuff into pretty-print.h. * diagnostic.c: Move non-diagnostic stuff into pretty-print.c. (format_with_decl): Remove. (diagnostic_for_decl): Likewise. (pedwarn_with_decl): Likewise. (warning_with_decl): Likewise. (error_with_decl): Likewise. (diagnostic_initialize): Adjust. (diagnostic_count_diagnostic): Likewise. (announce_function): Likewise. (lhd_print_error_function): Likewise. (diagnostic_report_current_module): Likewise. (default_diagnostic_starter): Likewise. (diagnostic_report_diagnostic): Likewise. (default_diagnostic_finalizer): Likewise. (verbatim): Likewise. (error): Likewise. (warning): Likewise. * opts.c (common_handle_option): Likewise. * pretty-print.c: New file. * c-pretty-print.h (pp_base): Override. * c-pretty-print.c: Adjust use of macros throughout. (pp_buffer): New macro. (pp_newline): Likewise. * c-objc-common.c (c_tree_printer): Adjust prototype. Tidy. * Makefile.in (DIAGNOSTIC_H): New variable. (c-errors.o): Use it. (c-objc-common.o): Likewise. (c-common.o): Likewise. (c-opts.o): Likewise. (c-format.o): Likewise. (diagnostic.o): Likewise. (opts.o): Likewise. (toplev.o): Likewise. (rtl-error.o): Likewise. (dwarf2out.o): Likewise. (jump.o): Likewise. (pretty-print.o): New rule. cp/ * Make-lang.in (cp/error.o): Depend on DIAGNOSTIC_H. * error.c: Use the new pretty-printer fraamework. From-SVN: r69773 --- gcc/toplev.c | 56 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 11 deletions(-) (limited to 'gcc/toplev.c') diff --git a/gcc/toplev.c b/gcc/toplev.c index 93fc185..144db98 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1659,11 +1659,11 @@ check_global_declarations (tree *vec, int len) && ! TREE_PUBLIC (decl)) { if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) - pedwarn_with_decl (decl, - "`%s' used but never defined"); + pedwarn ("%H'%F' used but never defined", + &DECL_SOURCE_LOCATION (decl), decl); else - warning_with_decl (decl, - "`%s' declared `static' but never defined"); + warning ("%H'%F' declared `static' but never defined", + &DECL_SOURCE_LOCATION (decl), decl); /* This symbol is effectively an "extern" declaration now. */ TREE_PUBLIC (decl) = 1; assemble_external (decl); @@ -1684,7 +1684,8 @@ check_global_declarations (tree *vec, int len) && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)) /* Otherwise, ask the language. */ && (*lang_hooks.decls.warn_unused_global) (decl)) - warning_with_decl (decl, "`%s' defined but not used"); + warning ("%H'%D' defined but not used", + &DECL_SOURCE_LOCATION (decl), decl); /* Avoid confusing the debug information machinery when there are errors. */ @@ -2512,8 +2513,15 @@ rest_of_handle_inlining (tree decl) timevar_pop (TV_INTEGRATION); if (lose || ! optimize) { - if (warn_inline && DECL_INLINE (decl)) - warning_with_decl (decl, lose); + if (warn_inline && lose && DECL_INLINE (decl)) + { + char *msg = xmalloc (2 + strlen (lose) + 1); + msg[0] = '%'; + msg[1] = 'H'; + strcpy(msg + 2, lose); + warning (msg, &DECL_SOURCE_LOCATION (decl)); + free (msg); + } DECL_ABSTRACT_ORIGIN (decl) = 0; /* Don't really compile an extern inline function. If we can't make it inline, pretend @@ -4091,6 +4099,29 @@ init_asm_output (const char *name) } } +/* Default tree printer. Handles declarations only. */ +static bool +default_tree_printer (pretty_printer * pp, text_info *text) +{ + switch (*text->format_spec) + { + case 'D': + case 'F': + case 'T': + { + tree t = va_arg (*text->args_ptr, tree); + const char *n = DECL_NAME (t) + ? (*lang_hooks.decl_printable_name) (t, 2) + : ""; + pp_string (pp, n); + } + return true; + + default: + return false; + } +} + /* Initialization of the front end environment, before command line options are parsed. Signal handlers, internationalization etc. ARGV0 is main's argv[0]. */ @@ -4110,6 +4141,13 @@ general_init (const char *argv0) gcc_init_libintl (); + /* Initialize the diagnostics reporting machinery, so option parsing + can give warnings and errors. */ + diagnostic_initialize (global_dc); + /* Set a default printer. Language specific initializations will + override it later. */ + pp_format_decoder (global_dc->printer) = &default_tree_printer; + /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */ #ifdef SIGSEGV signal (SIGSEGV, crash_signal); @@ -4133,10 +4171,6 @@ general_init (const char *argv0) /* Other host-specific signal setup. */ (*host_hooks.extra_signals)(); - /* Initialize the diagnostics reporting machinery, so option parsing - can give warnings and errors. */ - diagnostic_initialize (global_dc); - /* Initialize the garbage-collector, string pools and tree type hash table. */ init_ggc (); -- cgit v1.1