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
This commit is contained in:
Gabriel Dos Reis 2003-07-25 09:52:32 +00:00 committed by Gabriel Dos Reis
parent d5ff4e3f11
commit b6fe0bb8c5
23 changed files with 1336 additions and 1417 deletions

View File

@ -1,3 +1,75 @@
2003-07-25 Gabriel Dos Reis <gdr@integrable-solutions.net>
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.
2003-07-24 Roger Sayle <roger@eyesopen.com>
* builtins.def (BUILT_IN_PRINTF, BUILT_IN_FPRINTF): Changed from

View File

@ -652,6 +652,8 @@ C_TREE_H = c-tree.h $(C_COMMON_H)
SYSTEM_H = system.h hwint.h $(srcdir)/../include/libiberty.h
PREDICT_H = predict.h predict.def
CPPLIB_H = cpplib.h line-map.h
PRETTY_PRINT_H = pretty-print.h input.h $(OBSTACK_H)
DIAGNOSTIC_H = diagnostic.h diagnostic.def $(PRETTY_PRINT_H)
# sed inserts variable overrides after the following line.
####target overrides
@ -821,7 +823,7 @@ OBJS-common = \
sibcall.o simplify-rtx.o sreal.o ssa.o ssa-ccp.o ssa-dce.o stmt.o \
stor-layout.o stringpool.o timevar.o toplev.o tracer.o tree.o tree-dump.o \
unroll.o varasm.o varray.o version.o vmsdbgout.o xcoffout.o \
alloc-pool.o et-forest.o cfghooks.o bt-load.o $(GGC)
alloc-pool.o et-forest.o cfghooks.o bt-load.o pretty-print.o $(GGC)
OBJS-md = $(out_object_file)
OBJS-archive = $(EXTRA_OBJS) $(host_hook_obj) hashtable.o tree-inline.o \
@ -1238,7 +1240,7 @@ s-crt0: $(CRT0_S) $(MCRT0_S) $(GCC_PASSES) $(CONFIG_H)
# C language specific files.
c-errors.o: c-errors.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(C_TREE_H) flags.h diagnostic.h $(TM_P_H)
$(C_TREE_H) flags.h $(DIAGNOSTIC_H) $(TM_P_H)
c-parse.o : $(parsedir)/c-parse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(GGC_H) intl.h $(C_TREE_H) input.h flags.h toplev.h output.h $(CPPLIB_H) \
varray.h gt-c-parse.h
@ -1282,7 +1284,7 @@ c-ppoutput.o : c-ppoutput.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(C_COMMON_H) $(TREE_H) $(CPPLIB_H) cpphash.h $(TM_P_H) c-pragma.h
c-objc-common.o : c-objc-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(C_TREE_H) $(RTL_H) insn-config.h $(INTEGRATE_H) $(EXPR_H) $(C_TREE_H) \
flags.h toplev.h tree-inline.h diagnostic.h $(VARRAY_H) \
flags.h toplev.h tree-inline.h $(DIAGNOSTIC_H) $(VARRAY_H) \
langhooks.h $(GGC_H) gt-c-objc-common.h $(TARGET_H) cgraph.h
c-aux-info.o : c-aux-info.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(C_TREE_H) flags.h toplev.h
@ -1317,13 +1319,13 @@ tlink.o: tlink.c $(DEMANGLE_H) $(HASHTAB_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h
c-common.o : c-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(OBSTACK_H) $(C_COMMON_H) flags.h toplev.h output.h c-pragma.h intl.h \
$(GGC_H) $(EXPR_H) $(TM_P_H) builtin-types.def builtin-attrs.def \
diagnostic.h gt-c-common.h langhooks.h varray.h $(RTL_H) $(TARGET_H) \
$(C_TREE_H)
$(DIAGNOSTIC_H) gt-c-common.h langhooks.h varray.h $(RTL_H) \
$(TARGET_H) $(C_TREE_H)
c-pretty-print.o : c-pretty-print.c c-pretty-print.h pretty-print.h \
$(C_COMMON_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) real.h
c-opts.o : c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
c-pragma.h flags.h toplev.h langhooks.h tree-inline.h diagnostic.h \
c-pragma.h flags.h toplev.h langhooks.h tree-inline.h $(DIAGNOSTIC_H) \
intl.h debug.h $(C_COMMON_H) opts.h options.h $(PARAMS_H)
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$< $(OUTPUT_OPTION) @TARGET_SYSTEM_ROOT_DEFINE@
@ -1339,7 +1341,7 @@ attribs.o : attribs.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) flag
builtin-types.def $(TARGET_H) langhooks.h
c-format.o : c-format.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) langhooks.h \
$(C_COMMON_H) flags.h toplev.h intl.h diagnostic.h
$(C_COMMON_H) flags.h toplev.h intl.h $(DIAGNOSTIC_H)
c-semantics.o : c-semantics.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(C_TREE_H) flags.h toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) \
@ -1473,14 +1475,14 @@ stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE
langhooks.h
fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
flags.h real.h toplev.h $(HASHTAB_H) $(EXPR_H) $(RTL_H) $(GGC_H) $(TM_P_H) langhooks.h
diagnostic.o : diagnostic.c diagnostic.h real.h diagnostic.def \
diagnostic.o : diagnostic.c $(DIAGNOSTIC_H) real.h \
$(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(TM_P_H) flags.h $(GGC_H) \
input.h toplev.h intl.h langhooks.h $(LANGHOOKS_DEF_H)
opts.o : opts.c opts.h options.h toplev.h $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(TREE_H) $(TM_H) $(LANGHOOKS_H) $(GGC_H) $(RTL_H) \
output.h diagnostic.h $(TM_P_H) $(INSN_ATTR_H) intl.h
output.h $(DIAGNOSTIC_H) $(TM_P_H) $(INSN_ATTR_H) intl.h
toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) \
function.h flags.h xcoffout.h input.h $(INSN_ATTR_H) output.h diagnostic.h \
function.h flags.h xcoffout.h input.h $(INSN_ATTR_H) output.h $(DIAGNOSTIC_H) \
debug.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h \
dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) \
@ -1496,7 +1498,7 @@ host-default.o : host-default.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
hosthooks.h hosthooks-def.h
rtl-error.o: rtl-error.c $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(INSN_ATTR_H) \
insn-config.h input.h toplev.h intl.h diagnostic.h $(CONFIG_H)
insn-config.h input.h toplev.h intl.h $(DIAGNOSTIC_H) $(CONFIG_H)
rtl.o : rtl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(RTL_H) real.h \
$(GGC_H) errors.h
@ -1563,7 +1565,7 @@ dwarfout.o : dwarfout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(RTL_H) dwarf.h flags.h insn-config.h reload.h output.h toplev.h $(TM_P_H) \
debug.h langhooks.h $(TARGET_H)
dwarf2out.o : dwarf2out.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(RTL_H) dwarf2.h debug.h flags.h insn-config.h reload.h output.h diagnostic.h real.h \
$(RTL_H) dwarf2.h debug.h flags.h insn-config.h reload.h output.h $(DIAGNOSTIC_H) real.h \
hard-reg-set.h $(REGS_H) $(EXPR_H) libfuncs.h toplev.h dwarf2out.h varray.h \
$(GGC_H) except.h dwarf2asm.h $(TM_P_H) langhooks.h $(HASHTAB_H) \
gt-dwarf2out.h $(TARGET_H)
@ -1585,7 +1587,7 @@ integrate.o : integrate.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $
jump.o : jump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h \
hard-reg-set.h $(REGS_H) insn-config.h $(RECOG_H) $(EXPR_H) real.h except.h function.h \
toplev.h $(INSN_ATTR_H) $(TM_P_H) reload.h $(PREDICT_H) $(TIMEVAR_H) \
diagnostic.h
$(DIAGNOSTIC_H)
simplify-rtx.o : simplify-rtx.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(REGS_H) hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \
@ -1794,6 +1796,7 @@ ifcvt.o : ifcvt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
cfgloop.h
params.o : params.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(PARAMS_H) toplev.h
hooks.o: hooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(HOOKS_H)
pretty-print.o: pretty-print.c $(PRETTY_PRINT_H)
$(out_object_file): $(out_file) $(CONFIG_H) coretypes.h $(TM_H) $(TREE_H) $(GGC_H) \
$(RTL_H) $(REGS_H) hard-reg-set.h real.h insn-config.h conditions.h \

View File

@ -39,7 +39,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "target.h"
#include "cgraph.h"
static bool c_tree_printer (output_buffer *, text_info *);
static bool c_tree_printer (pretty_printer *, text_info *);
static tree inline_forbidden_p (tree *, int *, void *);
static void expand_deferred_fns (void);
static tree start_cdtor (int);
@ -416,7 +416,7 @@ c_objc_common_finish_file (void)
Please notice when called, the `%' part was already skipped by the
diagnostic machinery. */
static bool
c_tree_printer (output_buffer *buffer, text_info *text)
c_tree_printer (pretty_printer *pp, text_info *text)
{
tree t = va_arg (*text->args_ptr, tree);
@ -429,14 +429,14 @@ c_tree_printer (output_buffer *buffer, text_info *text)
const char *n = DECL_NAME (t)
? (*lang_hooks.decl_printable_name) (t, 2)
: "({anonymous})";
output_add_string (buffer, n);
pp_string (pp, n);
}
return true;
case 'E':
if (TREE_CODE (t) == IDENTIFIER_NODE)
{
output_add_string (buffer, IDENTIFIER_POINTER (t));
pp_string (pp, IDENTIFIER_POINTER (t));
return true;
}
return false;

View File

@ -74,6 +74,9 @@ static void pp_c_type_id (c_pretty_printer, tree);
static void pp_c_storage_class_specifier (c_pretty_printer, tree);
static void pp_c_function_specifier (c_pretty_printer, tree);
#define pp_buffer(PP) pp_base (PP)->buffer
#define pp_newline(PP) (pp_newline) (pp_base (PP))
/* Declarations. */
@ -248,9 +251,9 @@ pp_c_init_declarator (c_pretty_printer pp, tree t)
pp_declarator (pp, t);
if (DECL_INITIAL (t))
{
pp_whitespace (pp);
pp_space (pp);
pp_equal (pp);
pp_whitespace (pp);
pp_space (pp);
pp_c_initializer (pp, DECL_INITIAL (t));
}
}
@ -336,9 +339,9 @@ pp_c_char (c_pretty_printer ppi, int c)
break;
default:
if (ISPRINT (c))
pp_character (ppi, c);
pp_character (&ppi->base, c);
else
pp_format_scalar (ppi, "\\%03o", (unsigned) c);
pp_scalar (ppi, "\\%03o", (unsigned) c);
break;
}
}
@ -1038,7 +1041,7 @@ pp_c_assignment_expression (c_pretty_printer ppi, tree e)
pp_c_unary_expression (ppi, TREE_OPERAND (e, 0));
pp_c_maybe_whitespace (ppi);
pp_equal (ppi);
pp_whitespace (ppi);
pp_space (ppi);
pp_c_assignment_expression (ppi, TREE_OPERAND (e, 1));
}
else
@ -1234,7 +1237,7 @@ pp_c_statement (c_pretty_printer ppi, tree stmt)
case IF_STMT:
pp_c_identifier (ppi, "if");
pp_whitespace (ppi);
pp_space (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, IF_COND (stmt));
pp_right_paren (ppi);
@ -1258,7 +1261,7 @@ pp_c_statement (c_pretty_printer ppi, tree stmt)
case SWITCH_STMT:
pp_newline (ppi);
pp_c_identifier (ppi, "switch");
pp_whitespace (ppi);
pp_space (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, SWITCH_COND (stmt));
pp_right_paren (ppi);
@ -1269,7 +1272,7 @@ pp_c_statement (c_pretty_printer ppi, tree stmt)
case WHILE_STMT:
pp_c_identifier (ppi, "while");
pp_whitespace (ppi);
pp_space (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, WHILE_COND (stmt));
pp_right_paren (ppi);
@ -1284,7 +1287,7 @@ pp_c_statement (c_pretty_printer ppi, tree stmt)
pp_statement (ppi, DO_BODY (stmt));
pp_newline_and_indent (ppi, -3);
pp_c_identifier (ppi, "while");
pp_whitespace (ppi);
pp_space (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, DO_COND (stmt));
pp_c_right_paren (ppi);
@ -1294,7 +1297,7 @@ pp_c_statement (c_pretty_printer ppi, tree stmt)
case FOR_STMT:
pp_c_identifier (ppi, "for");
pp_whitespace (ppi);
pp_space (ppi);
pp_c_left_paren (ppi);
pp_statement (ppi, FOR_INIT_STMT (stmt));
pp_c_whitespace (ppi);
@ -1364,20 +1367,20 @@ pp_c_statement (c_pretty_printer ppi, tree stmt)
pp_c_identifier (ppi, is_extended ? "__asm__" : "asm");
if (has_volatile_p)
pp_c_identifier (ppi, "__volatile__");
pp_whitespace (ppi);
pp_space (ppi);
pp_c_left_paren (ppi);
pp_c_string_literal (ppi, ASM_STRING (stmt));
if (is_extended)
{
pp_whitespace (ppi);
pp_space (ppi);
pp_separate_with (ppi, ':');
if (ASM_OUTPUTS (stmt))
pp_c_expression (ppi, ASM_OUTPUTS (stmt));
pp_whitespace (ppi);
pp_space (ppi);
pp_separate_with (ppi, ':');
if (ASM_INPUTS (stmt))
pp_c_expression (ppi, ASM_INPUTS (stmt));
pp_whitespace (ppi);
pp_space (ppi);
pp_separate_with (ppi, ':');
if (ASM_CLOBBERS (stmt))
pp_c_expression (ppi, ASM_CLOBBERS (stmt));
@ -1389,7 +1392,7 @@ pp_c_statement (c_pretty_printer ppi, tree stmt)
case FILE_STMT:
pp_c_identifier (ppi, "__FILE__");
pp_whitespace (ppi);
pp_space (ppi);
pp_equal (ppi);
pp_c_whitespace (ppi);
pp_c_identifier (ppi, FILE_STMT_FILENAME (stmt));

View File

@ -62,6 +62,9 @@ struct c_pretty_print_info
c_pretty_print_fn assignment_expression;
};
#undef pp_base
#define pp_base(PP) (&pp_c_base (PP)->base)
#define pp_c_left_paren(PPI) \
do { \
pp_left_paren (PPI); \
@ -84,7 +87,7 @@ struct c_pretty_print_info
} while (0)
#define pp_c_whitespace(PPI) \
do { \
pp_whitespace (PPI); \
pp_space (PPI); \
pp_c_base (PPI)->base.padding = pp_none; \
} while (0)
#define pp_c_maybe_whitespace(PPI) \
@ -102,10 +105,6 @@ struct c_pretty_print_info
#define pp_c_tree_identifier(PPI, ID) \
pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
/* Returns the 'output_buffer *' associated with a PRETTY-PRINTER, the latter
being something digestible by pp_c_base. */
#define pp_buffer(PPI) pp_c_base (PPI)->base.buffer
#define pp_declaration(PPI, T) \
(*pp_c_base (PPI)->declaration) (pp_c_base (PPI), T)
#define pp_declaration_specifiers(PPI, D) \

View File

@ -1808,7 +1808,8 @@ try_to_integrate (tree fndecl, tree actparms, rtx target, int ignore,
if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
&& optimize > 0 && !TREE_ADDRESSABLE (fndecl))
{
warning_with_decl (fndecl, "inlining failed in call to `%s'");
warning ("%Hinlining failed in call to '%F'",
&DECL_SOURCE_LOCATION (fndecl), fndecl);
warning ("called from here");
}
(*lang_hooks.mark_addressable) (fndecl);
@ -2147,7 +2148,8 @@ expand_call (tree exp, rtx target, int ignore)
if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
&& optimize > 0)
{
warning_with_decl (fndecl, "can't inline call to `%s'");
warning ("%Hcan't inline call to '%F'",
&DECL_SOURCE_LOCATION (fndecl), fndecl);
warning ("called from here");
}
(*lang_hooks.mark_addressable) (fndecl);

View File

@ -1,3 +1,8 @@
2003-07-25 Gabriel Dos Reis <gdr@integrable-solutions.net>
* Make-lang.in (cp/error.o): Depend on DIAGNOSTIC_H.
* error.c: Use the new pretty-printer fraamework.
2003-07-24 Per Bothner <pbothner@apple.com>
* decl.c (pushdecl_class_level): Don't use push_srcloc/pop_srcloc

View File

@ -265,8 +265,8 @@ cp/expr.o: cp/expr.c $(CXX_TREE_H) $(TM_H) $(RTL_H) flags.h $(EXPR_H) toplev.h \
except.h $(TM_P_H)
cp/pt.o: cp/pt.c $(CXX_TREE_H) $(TM_H) cp/decl.h cp/lex.h \
toplev.h $(RTL_H) except.h tree-inline.h gt-cp-pt.h
cp/error.o: cp/error.c $(CXX_TREE_H) $(TM_H) toplev.h diagnostic.h flags.h real.h \
$(LANGHOOKS_DEF_H)
cp/error.o: cp/error.c $(CXX_TREE_H) $(TM_H) toplev.h $(DIAGNOSTIC_H) \
flags.h real.h $(LANGHOOKS_DEF_H)
cp/repo.o: cp/repo.c $(CXX_TREE_H) $(TM_H) toplev.h diagnostic.h \
gt-cp-repo.h
cp/semantics.o: cp/semantics.c $(CXX_TREE_H) $(TM_H) cp/lex.h except.h toplev.h \

File diff suppressed because it is too large Load Diff

View File

@ -39,56 +39,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "langhooks.h"
#include "langhooks-def.h"
#define output_text_length(BUFFER) (BUFFER)->line_length
#define is_starting_newline(BUFFER) (output_text_length (BUFFER) == 0)
#define line_wrap_cutoff(BUFFER) (BUFFER)->state.maximum_length
#define prefix_was_emitted_for(BUFFER) (BUFFER)->state.emitted_prefix_p
/* Format an integer given by va_arg (ARG, type-specifier T) where
type-specifier is a precision modifier as indicated by PREC. F is
a string used to construct the appropriate format-specifier. */
#define output_integer_with_precision(BUFFER, ARG, PREC, T, F) \
do \
switch (PREC) \
{ \
case 0: \
output_formatted_scalar \
(BUFFER, "%" F, va_arg (ARG, T)); \
break; \
\
case 1: \
output_formatted_scalar \
(BUFFER, "%l" F, va_arg (ARG, long T)); \
break; \
\
case 2: \
output_formatted_scalar \
(BUFFER, "%ll" F, va_arg (ARG, long long T)); \
break; \
\
default: \
break; \
} \
while (0)
/* Prototypes. */
static void output_flush (output_buffer *);
static void output_do_verbatim (output_buffer *, text_info *);
static void output_buffer_to_stream (output_buffer *);
static void output_format (output_buffer *, text_info *);
static void output_indent (output_buffer *);
static char *build_message_string (const char *, ...)
ATTRIBUTE_PRINTF_1;
static void format_with_decl (output_buffer *, text_info *, tree);
static void diagnostic_for_decl (diagnostic_context *, diagnostic_info *,
tree);
static void set_real_maximum_length (output_buffer *);
static void output_append_r (output_buffer *, const char *, int);
static void wrap_text (output_buffer *, const char *, const char *);
static void maybe_wrap_text (output_buffer *, const char *, const char *);
static void output_clear_data (output_buffer *);
static char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1;
static void default_diagnostic_starter (diagnostic_context *,
diagnostic_info *);
@ -116,482 +69,6 @@ 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. */
static void
set_real_maximum_length (output_buffer *buffer)
{
/* If we're told not to wrap lines then do the obvious thing. In case
we'll emit prefix only once per diagnostic message, it is appropriate
not to increase unnecessarily the line-length cut-off. */
if (!output_is_line_wrapping (buffer)
|| output_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE
|| output_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
line_wrap_cutoff (buffer) = output_line_cutoff (buffer);
else
{
int prefix_length = buffer->state.prefix ?
strlen (buffer->state.prefix) : 0;
/* If the prefix is ridiculously too long, output at least
32 characters. */
if (output_line_cutoff (buffer) - prefix_length < 32)
line_wrap_cutoff (buffer) = output_line_cutoff (buffer) + 32;
else
line_wrap_cutoff (buffer) = output_line_cutoff (buffer);
}
}
/* Sets the number of maximum characters per line BUFFER can output
in line-wrapping mode. A LENGTH value 0 suppresses line-wrapping. */
void
output_set_maximum_length (output_buffer *buffer, int length)
{
output_line_cutoff (buffer) = length;
set_real_maximum_length (buffer);
}
/* Sets BUFFER's PREFIX. */
void
output_set_prefix (output_buffer *buffer, const char *prefix)
{
buffer->state.prefix = prefix;
set_real_maximum_length (buffer);
prefix_was_emitted_for (buffer) = false;
output_indentation (buffer) = 0;
}
/* Return a pointer to the last character emitted in the output
BUFFER area. A NULL pointer means no character available. */
const char *
output_last_position (const output_buffer *buffer)
{
const char *p = NULL;
if (obstack_base (&buffer->obstack) != obstack_next_free (&buffer->obstack))
p = ((const char *) obstack_next_free (&buffer->obstack)) - 1;
return p;
}
/* Free BUFFER's prefix, a previously malloc'd string. */
void
output_destroy_prefix (output_buffer *buffer)
{
if (buffer->state.prefix != NULL)
{
free ((char *) buffer->state.prefix);
buffer->state.prefix = NULL;
}
}
/* Zero out any text output so far in BUFFER. */
void
output_clear_message_text (output_buffer *buffer)
{
obstack_free (&buffer->obstack, obstack_base (&buffer->obstack));
output_text_length (buffer) = 0;
}
/* Zero out any formatting data used so far by BUFFER. */
static void
output_clear_data (output_buffer *buffer)
{
prefix_was_emitted_for (buffer) = false;
output_indentation (buffer) = 0;
}
/* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
characters per line. */
void
init_output_buffer (output_buffer *buffer, const char *prefix,
int maximum_length)
{
memset (buffer, 0, sizeof (output_buffer));
obstack_init (&buffer->obstack);
output_buffer_attached_stream (buffer) = stderr;
output_line_cutoff (buffer) = maximum_length;
output_prefixing_rule (buffer) = diagnostic_prefixing_rule (global_dc);
output_set_prefix (buffer, prefix);
output_text_length (buffer) = 0;
output_clear_data (buffer);
}
/* Reinitialize BUFFER. */
void
output_clear (output_buffer *buffer)
{
output_clear_message_text (buffer);
output_clear_data (buffer);
}
/* Finishes constructing a NULL-terminated character string representing
the BUFFERed message. */
const char *
output_finalize_message (output_buffer *buffer)
{
obstack_1grow (&buffer->obstack, '\0');
return output_message_text (buffer);
}
/* Return the amount of characters BUFFER can accept to
make a full line. */
int
output_space_left (const output_buffer *buffer)
{
return line_wrap_cutoff (buffer) - output_text_length (buffer);
}
/* Write out BUFFER's prefix. */
void
output_emit_prefix (output_buffer *buffer)
{
if (buffer->state.prefix != NULL)
{
switch (output_prefixing_rule (buffer))
{
default:
case DIAGNOSTICS_SHOW_PREFIX_NEVER:
break;
case DIAGNOSTICS_SHOW_PREFIX_ONCE:
if (prefix_was_emitted_for (buffer))
{
output_indent (buffer);
break;
}
output_indentation (buffer) += 3;
/* Fall through. */
case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
{
int prefix_length = strlen (buffer->state.prefix);
output_append_r (buffer, buffer->state.prefix, prefix_length);
prefix_was_emitted_for (buffer) = true;
}
break;
}
}
}
/* Have BUFFER start a new line. */
void
output_add_newline (output_buffer *buffer)
{
obstack_1grow (&buffer->obstack, '\n');
output_text_length (buffer) = 0;
}
/* Appends a character to BUFFER. */
void
output_add_character (output_buffer *buffer, int c)
{
if (output_is_line_wrapping (buffer) && output_space_left (buffer) <= 0)
output_add_newline (buffer);
obstack_1grow (&buffer->obstack, c);
++output_text_length (buffer);
}
/* Adds a space to BUFFER. */
void
output_add_space (output_buffer *buffer)
{
if (output_is_line_wrapping (buffer) && output_space_left (buffer) <= 0)
{
output_add_newline (buffer);
return;
}
obstack_1grow (&buffer->obstack, ' ');
++output_text_length (buffer);
}
/* These functions format an INTEGER into BUFFER as suggested by their
names. */
void
output_decimal (output_buffer *buffer, int i)
{
output_formatted_scalar (buffer, "%d", i);
}
void
output_host_wide_integer (output_buffer *buffer, HOST_WIDE_INT i)
{
output_formatted_scalar (buffer, HOST_WIDE_INT_PRINT_DEC, i);
}
static inline void
output_pointer (output_buffer *buffer, void *p)
{
output_formatted_scalar (buffer, HOST_PTR_PRINTF, p);
}
/* Append to BUFFER a string specified by its STARTING character
and LENGTH. */
static void
output_append_r (output_buffer *buffer, const char *start, int length)
{
obstack_grow (&buffer->obstack, start, length);
output_text_length (buffer) += length;
}
/* Append a string delimited by START and END to BUFFER. No wrapping is
done. However, if beginning a new line then emit BUFFER->state.prefix
and skip any leading whitespace if appropriate. The caller must ensure
that it is safe to do so. */
void
output_append (output_buffer *buffer, const char *start, const char *end)
{
/* Emit prefix and skip whitespace if we're starting a new line. */
if (is_starting_newline (buffer))
{
output_emit_prefix (buffer);
if (output_is_line_wrapping (buffer))
while (start != end && *start == ' ')
++start;
}
output_append_r (buffer, start, end - start);
}
/* Insert enough spaces into BUFFER to bring the column position to
the current indentation level, assuming that a newline has just
been written to the buffer. */
static void
output_indent (output_buffer *buffer)
{
int n = output_indentation (buffer);
int i;
for (i = 0; i < n; ++i)
output_add_character (buffer, ' ');
}
/* Wrap a text delimited by START and END into BUFFER. */
static void
wrap_text (output_buffer *buffer, const char *start, const char *end)
{
bool is_wrapping = output_is_line_wrapping (buffer);
while (start != end)
{
/* Dump anything bordered by whitespaces. */
{
const char *p = start;
while (p != end && *p != ' ' && *p != '\n')
++p;
if (is_wrapping && p - start >= output_space_left (buffer))
output_add_newline (buffer);
output_append (buffer, start, p);
start = p;
}
if (start != end && *start == ' ')
{
output_add_space (buffer);
++start;
}
if (start != end && *start == '\n')
{
output_add_newline (buffer);
++start;
}
}
}
/* Same as wrap_text but wrap text only when in line-wrapping mode. */
static void
maybe_wrap_text (output_buffer *buffer, const char *start, const char *end)
{
if (output_is_line_wrapping (buffer))
wrap_text (buffer, start, end);
else
output_append (buffer, start, end);
}
/* Append a STRING to BUFFER; the STRING might be line-wrapped if in
appropriate mode. */
void
output_add_string (output_buffer *buffer, const char *str)
{
maybe_wrap_text (buffer, str, str + (str ? strlen (str) : 0));
}
/* Append an identifier ID to BUFFER. */
void
output_add_identifier (output_buffer *buffer, tree id)
{
output_append (buffer, IDENTIFIER_POINTER (id),
IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
}
/* Flush the content of BUFFER onto the attached stream,
and reinitialize. */
static void
output_buffer_to_stream (output_buffer *buffer)
{
const char *text = output_finalize_message (buffer);
fputs (text, output_buffer_attached_stream (buffer));
output_clear_message_text (buffer);
}
/* Format a message pointed to by TEXT. The following format specifiers are
recognized as being language independent:
%d, %i: (signed) integer in base ten.
%u: unsigned integer in base ten.
%o: unsigned integer in base eight.
%x: unsigned integer in base sixteen.
%ld, %li, %lo, %lu, %lx: long versions of the above.
%lld, %lli, %llo, %llu, %llx: long long versions.
%wd, %wi, %wo, %wu, %wx: HOST_WIDE_INT versions.
%c: character.
%s: string.
%p: pointer.
%m: strerror(text->err_no) - does not consume a value from args_ptr.
%%: `%'.
%*.s: a substring the length of which is specified by an integer.
%H: location_t. */
static void
output_format (output_buffer *buffer, text_info *text)
{
for (; *text->format_spec; ++text->format_spec)
{
int precision = 0;
bool wide = false;
/* Ignore text. */
{
const char *p = text->format_spec;
while (*p && *p != '%')
++p;
wrap_text (buffer, text->format_spec, p);
text->format_spec = p;
}
if (*text->format_spec == '\0')
break;
/* We got a '%'. Parse precision modifiers, if any. */
switch (*++text->format_spec)
{
case 'w':
wide = true;
++text->format_spec;
break;
case 'l':
do
++precision;
while (*++text->format_spec == 'l');
break;
default:
break;
}
/* We don't support precision behond that of "long long". */
if (precision > 2)
abort();
switch (*text->format_spec)
{
case 'c':
output_add_character (buffer, va_arg (*text->args_ptr, int));
break;
case 'd':
case 'i':
if (wide)
output_formatted_scalar
(buffer, HOST_WIDE_INT_PRINT_DEC,
va_arg (*text->args_ptr, HOST_WIDE_INT));
else
output_integer_with_precision
(buffer, *text->args_ptr, precision, int, "d");
break;
case 'o':
if (wide)
output_formatted_scalar
(buffer, "%" HOST_WIDE_INT_PRINT "o",
va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
else
output_integer_with_precision
(buffer, *text->args_ptr, precision, unsigned, "u");
break;
case 's':
output_add_string (buffer, va_arg (*text->args_ptr, const char *));
break;
case 'p':
output_pointer (buffer, va_arg (*text->args_ptr, void *));
break;
case 'u':
if (wide)
output_formatted_scalar
(buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
else
output_integer_with_precision
(buffer, *text->args_ptr, precision, unsigned, "u");
break;
case 'x':
if (wide)
output_formatted_scalar
(buffer, HOST_WIDE_INT_PRINT_HEX,
va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
else
output_integer_with_precision
(buffer, *text->args_ptr, precision, unsigned, "x");
break;
case 'm':
output_add_string (buffer, xstrerror (text->err_no));
break;
case '%':
output_add_character (buffer, '%');
break;
case 'H':
{
const location_t *locus = va_arg (*text->args_ptr, location_t *);
output_add_string (buffer, "file '");
output_add_string (buffer, locus->file);
output_add_string (buffer, "', line ");
output_decimal (buffer, locus->line);
}
break;
case '.':
{
int n;
const char *s;
/* We handle no precision specifier but `%.*s'. */
if (*++text->format_spec != '*')
abort ();
else if (*++text->format_spec != 's')
abort ();
n = va_arg (*text->args_ptr, int);
s = va_arg (*text->args_ptr, const char *);
output_append (buffer, s, s + n);
}
break;
default:
if (!buffer->format_decoder
|| !(*buffer->format_decoder) (buffer, text))
{
/* Hmmm. The front-end failed to install a format translator
but called us with an unrecognized format. Or, maybe, the
translated string just contains an invalid format, or
has formats in the wrong order. Sorry. */
abort ();
}
}
}
}
/* Return a malloc'd string containing MSG formatted a la printf. The
caller is responsible for freeing the memory. */
static char *
@ -614,127 +91,31 @@ file_name_as_prefix (const char *f)
return build_message_string ("%s: ", f);
}
/* Format a message into BUFFER a la printf. */
void
output_printf (struct output_buffer *buffer, const char *msgid, ...)
{
text_info text;
va_list ap;
va_start (ap, msgid);
text.err_no = errno;
text.args_ptr = &ap;
text.format_spec = _(msgid);
output_format (buffer, &text);
va_end (ap);
}
/* Print a message relevant to the given DECL. */
static void
format_with_decl (output_buffer *buffer, text_info *text, tree decl)
{
const char *p;
/* Do magic to get around lack of varargs support for insertion
of arguments into existing list. We know that the decl is first;
we ass_u_me that it will be printed with "%s". */
for (p = text->format_spec; *p; ++p)
{
if (*p == '%')
{
if (*(p + 1) == '%')
++p;
else if (*(p + 1) != 's')
abort ();
else
break;
}
}
/* Print the left-hand substring. */
maybe_wrap_text (buffer, text->format_spec, p);
if (*p == '%') /* Print the name. */
{
const char *const n = (DECL_NAME (decl)
? (*lang_hooks.decl_printable_name) (decl, 2)
: _("((anonymous))"));
output_add_string (buffer, n);
while (*p)
{
++p;
if (ISALPHA (*(p - 1) & 0xFF))
break;
}
}
if (*p) /* Print the rest of the message. */
{
text->format_spec = p;
output_format (buffer, text);
}
}
/* Flush the content of BUFFER onto the attached stream. */
static void
output_flush (output_buffer *buffer)
{
output_buffer_to_stream (buffer);
output_clear_data (buffer);
fputc ('\n', output_buffer_attached_stream (buffer));
fflush (output_buffer_attached_stream (buffer));
}
/* Helper subroutine of output_verbatim and verbatim. Do the appropriate
settings needed by BUFFER for a verbatim formatting. */
static void
output_do_verbatim (output_buffer *buffer, text_info *text)
{
diagnostic_prefixing_rule_t rule = output_prefixing_rule (buffer);
int line_cutoff = output_line_cutoff (buffer);
/* Set verbatim mode. */
output_prefixing_rule (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
output_line_cutoff (buffer) = 0;
/* Do the actual formatting. */
output_format (buffer, text);
/* Restore previous settings. */
output_prefixing_rule (buffer) = rule;
output_line_cutoff (buffer) = line_cutoff;
}
/* Output MESSAGE verbatim into BUFFER. */
void
output_verbatim (output_buffer *buffer, const char *msgid, ...)
{
text_info text;
va_list ap;
va_start (ap, msgid);
text.err_no = errno;
text.args_ptr = &ap;
text.format_spec = _(msgid);
output_do_verbatim (buffer, &text);
va_end (ap);
}
/* Initialize the diagnostic message outputting machinery. */
void
diagnostic_initialize (diagnostic_context *context)
{
memset (context, 0, sizeof *context);
obstack_init (&context->buffer.obstack);
/* Allocate a basic pretty-printer. Clients will replace this a
much more elaborated pretty-printer if they wish. */
context->printer = xmalloc (sizeof (pretty_printer));
pp_construct (context->printer, NULL, 0);
/* By default, diagnostics are sent to stderr. */
output_buffer_attached_stream (&context->buffer) = stderr;
context->printer->buffer->stream = stderr;
/* By default, we emit prefixes once per message. */
diagnostic_prefixing_rule (context) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
context->printer->prefixing_rule = DIAGNOSTICS_SHOW_PREFIX_ONCE;
memset (context->diagnostic_count, 0, sizeof context->diagnostic_count);
context->warnings_are_errors_message = warnings_are_errors;
context->abort_on_error = false;
context->internal_error = NULL;
diagnostic_starter (context) = default_diagnostic_starter;
diagnostic_finalizer (context) = default_diagnostic_finalizer;
context->warnings_are_errors_message = warnings_are_errors;
context->last_module = 0;
context->last_function = NULL;
context->lock = 0;
context->x_data = NULL;
}
/* Returns true if the next format specifier in TEXT is a format specifier
@ -797,13 +178,6 @@ diagnostic_build_prefix (diagnostic_info *diagnostic)
_(diagnostic_kind_text[diagnostic->kind]));
}
void
diagnostic_flush_buffer (diagnostic_context *context)
{
output_buffer_to_stream (&context->buffer);
fflush (output_buffer_attached_stream (&context->buffer));
}
/* Count a diagnostic. Return true if the message should be printed. */
static bool
diagnostic_count_diagnostic (diagnostic_context *context,
@ -852,8 +226,8 @@ diagnostic_count_diagnostic (diagnostic_context *context,
if (context->warnings_are_errors_message)
{
output_verbatim (&context->buffer,
"%s: warnings being treated as errors\n", progname);
pp_verbatim (context->printer,
"%s: warnings being treated as errors\n", progname);
context->warnings_are_errors_message = false;
}
@ -917,7 +291,7 @@ announce_function (tree decl)
else
verbatim (" %s", (*lang_hooks.decl_printable_name) (decl, 2));
fflush (stderr);
output_needs_newline (&global_dc->buffer) = true;
global_dc->printer->need_newline = true;
diagnostic_set_last_function (global_dc);
}
}
@ -929,29 +303,29 @@ lhd_print_error_function (diagnostic_context *context, const char *file)
{
if (diagnostic_last_function_changed (context))
{
const char *old_prefix = output_prefix (&context->buffer);
const char *old_prefix = context->printer->prefix;
char *new_prefix = file ? build_message_string ("%s: ", file) : NULL;
output_set_prefix (&context->buffer, new_prefix);
pp_set_prefix (context->printer, new_prefix);
if (current_function_decl == NULL)
output_add_string (&context->buffer, _("At top level:"));
pp_string (context->printer, _("At top level:"));
else
{
if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
output_printf
(&context->buffer, "In member function `%s':",
pp_printf
(context->printer, "In member function `%s':",
(*lang_hooks.decl_printable_name) (current_function_decl, 2));
else
output_printf
(&context->buffer, "In function `%s':",
pp_printf
(context->printer, "In function `%s':",
(*lang_hooks.decl_printable_name) (current_function_decl, 2));
}
output_add_newline (&context->buffer);
pp_newline (context->printer);
diagnostic_set_last_function (context);
output_buffer_to_stream (&context->buffer);
context->buffer.state.prefix = old_prefix;
pp_flush (context->printer);
context->printer->prefix = old_prefix;
free ((char*) new_prefix);
}
}
@ -972,23 +346,23 @@ diagnostic_report_current_module (diagnostic_context *context)
{
struct file_stack *p;
if (output_needs_newline (&context->buffer))
if (pp_needs_newline (context->printer))
{
output_add_newline (&context->buffer);
output_needs_newline (&context->buffer) = false;
pp_newline (context->printer);
pp_needs_newline (context->printer) = false;
}
if (input_file_stack && diagnostic_last_module_changed (context))
{
p = input_file_stack;
output_verbatim (&context->buffer,
"In file included from %s:%d",
p->location.file, p->location.line);
pp_verbatim (context->printer,
"In file included from %s:%d",
p->location.file, p->location.line);
while ((p = p->next) != NULL)
output_verbatim (&context->buffer,
",\n from %s:%d",
p->location.file, p->location.line);
output_verbatim (&context->buffer, ":\n");
pp_verbatim (context->printer,
",\n from %s:%d",
p->location.file, p->location.line);
pp_verbatim (context->printer, ":\n");
diagnostic_set_last_module (context);
}
}
@ -998,14 +372,14 @@ default_diagnostic_starter (diagnostic_context *context,
diagnostic_info *diagnostic)
{
diagnostic_report_current_function (context);
output_set_prefix (&context->buffer, diagnostic_build_prefix (diagnostic));
pp_set_prefix (context->printer, diagnostic_build_prefix (diagnostic));
}
static void
default_diagnostic_finalizer (diagnostic_context *context,
diagnostic_info *diagnostic __attribute__((unused)))
{
output_destroy_prefix (&context->buffer);
pp_destroy_prefix (context->printer);
}
/* Report a diagnostic message (an error or a warning) as specified by
@ -1024,31 +398,9 @@ diagnostic_report_diagnostic (diagnostic_context *context,
if (diagnostic_count_diagnostic (context, diagnostic))
{
(*diagnostic_starter (context)) (context, diagnostic);
output_format (&context->buffer, &diagnostic->message);
pp_format_text (context->printer, &diagnostic->message);
(*diagnostic_finalizer (context)) (context, diagnostic);
output_flush (&context->buffer);
diagnostic_action_after_output (context, diagnostic);
}
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_context *context,
diagnostic_info *diagnostic, tree decl)
{
if (context->lock++ && diagnostic->kind < DK_SORRY)
error_recursion (context);
if (diagnostic_count_diagnostic (context, diagnostic))
{
(*diagnostic_starter (context)) (context, diagnostic);
format_with_decl (&context->buffer, &diagnostic->message, decl);
(*diagnostic_finalizer (context)) (context, diagnostic);
output_flush (&context->buffer);
pp_flush (context->printer);
diagnostic_action_after_output (context, diagnostic);
}
@ -1114,8 +466,8 @@ verbatim (const char *msgid, ...)
text.err_no = errno;
text.args_ptr = &ap;
text.format_spec = _(msgid);
output_do_verbatim (&global_dc->buffer, &text);
output_buffer_to_stream (&global_dc->buffer);
pp_format_verbatim (global_dc->printer, &text);
pp_flush (global_dc->printer);
va_end (ap);
}
@ -1234,61 +586,6 @@ internal_error (const char *msgid, ...)
real_abort ();
}
/* Variants of some of the above, which make reference to a particular
DECL node. These are deprecated. */
void
warning_with_decl (tree decl, const char *msgid, ...)
{
diagnostic_info diagnostic;
va_list ap;
va_start (ap, 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_LOCATION (decl), DK_WARNING);
diagnostic_for_decl (global_dc, &diagnostic, decl);
va_end (ap);
}
void
pedwarn_with_decl (tree decl, const char *msgid, ...)
{
diagnostic_info diagnostic;
va_list ap;
va_start (ap, 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_LOCATION (decl), pedantic_error_kind ());
diagnostic_for_decl (global_dc, &diagnostic, decl);
va_end (ap);
}
void
error_with_decl (tree decl, const char *msgid, ...)
{
diagnostic_info diagnostic;
va_list ap;
va_start (ap, msgid);
diagnostic_set_info (&diagnostic, msgid, &ap,
DECL_SOURCE_LOCATION (decl), DK_ERROR);
diagnostic_for_decl (global_dc, &diagnostic, decl);
va_end (ap);
}
/* Special case error functions. Most are implemented in terms of the
above, or should be. */
@ -1351,7 +648,7 @@ static void
error_recursion (diagnostic_context *context)
{
if (context->lock < 3)
output_flush (&context->buffer);
pp_flush (context->printer);
fnotice (stderr,
"Internal compiler error: Error reporting routines re-entered.\n");

View File

@ -22,17 +22,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifndef GCC_DIAGNOSTIC_H
#define GCC_DIAGNOSTIC_H
#include "obstack.h"
#include "input.h"
/* The type of a text to be formatted according a format specification
along with a list of things. */
typedef struct
{
const char *format_spec;
va_list *args_ptr;
int err_no; /* for %m */
} text_info;
#include "pretty-print.h"
/* Constants used to discriminate diagnostics. */
typedef enum
@ -56,118 +46,6 @@ typedef struct
#define pedantic_error_kind() (flag_pedantic_errors ? DK_ERROR : DK_WARNING)
/* How often diagnostics are prefixed by their locations:
o DIAGNOSTICS_SHOW_PREFIX_NEVER: never - not yet supported;
o DIAGNOSTICS_SHOW_PREFIX_ONCE: emit only once;
o DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE: emit each time a physical
line is started. */
typedef enum
{
DIAGNOSTICS_SHOW_PREFIX_ONCE = 0x0,
DIAGNOSTICS_SHOW_PREFIX_NEVER = 0x1,
DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE = 0x2
} diagnostic_prefixing_rule_t;
/* This data structure encapsulates an output_buffer's state. */
typedef struct
{
/* The prefix for each new line. */
const char *prefix;
/* The real upper bound of number of characters per line, taking into
account the case of a very very looong prefix. */
int maximum_length;
/* The ideal upper bound of number of characters per line, as suggested
by front-end. */
int ideal_maximum_length;
/* Indentation count. */
int indent_skip;
/* Nonzero if current PREFIX was emitted at least once. */
bool emitted_prefix_p;
/* Nonzero means one should emit a newline before outputting anything. */
bool need_newline_p;
/* Current prefixing rule. */
diagnostic_prefixing_rule_t prefixing_rule;
} output_state;
/* The type of a hook that formats client-specific data (trees mostly) into
an output_buffer. A client-supplied formatter returns true if everything
goes well. */
typedef struct output_buffer output_buffer;
typedef bool (*printer_fn) (output_buffer *, text_info *);
/* The output buffer datatype. This is best seen as an abstract datatype
whose fields should not be accessed directly by clients. */
struct output_buffer
{
/* The current state of the buffer. */
output_state state;
/* Where to output formatted text. */
FILE* stream;
/* The obstack where the text is built up. */
struct obstack obstack;
/* The amount of characters output so far. */
int line_length;
/* This must be large enough to hold any printed integer or
floating-point value. */
char digit_buffer[128];
/* If non-NULL, this function formats a TEXT into the BUFFER. When called,
TEXT->format_spec points to a format code. FORMAT_DECODER should call
output_add_string (and related functions) to add data to the BUFFER.
FORMAT_DECODER can read arguments from *TEXT->args_pts using VA_ARG.
If the BUFFER needs additional characters from the format string, it
should advance the TEXT->format_spec as it goes. When FORMAT_DECODER
returns, TEXT->format_spec should point to the last character processed.
*/
printer_fn format_decoder;
} ;
#define output_prefix(BUFFER) (BUFFER)->state.prefix
/* The stream attached to the output_buffer, where the formatted
diagnostics will ultimately go. Works only on `output_buffer *'. */
#define output_buffer_attached_stream(BUFFER) (BUFFER)->stream
/* In line-wrapping mode, whether we should start a new line. */
#define output_needs_newline(BUFFER) (BUFFER)->state.need_newline_p
/* The amount of whitespace to be emitted when starting a new line. */
#define output_indentation(BUFFER) (BUFFER)->state.indent_skip
/* A pointer to the formatted diagnostic message. */
#define output_message_text(BUFFER) \
((const char *) obstack_base (&(BUFFER)->obstack))
/* Client supplied function used to decode formats. */
#define output_format_decoder(BUFFER) (BUFFER)->format_decoder
/* Prefixing rule used in formatting a diagnostic message. */
#define output_prefixing_rule(BUFFER) (BUFFER)->state.prefixing_rule
/* Maximum characters per line in automatic line wrapping mode.
Zero means don't wrap lines. */
#define output_line_cutoff(BUFFER) (BUFFER)->state.ideal_maximum_length
/* True if BUFFER is in line-wrapping mode. */
#define output_is_line_wrapping(BUFFER) (output_line_cutoff (BUFFER) > 0)
#define output_formatted_scalar(BUFFER, FORMAT, SCALAR) \
do \
{ \
sprintf ((BUFFER)->digit_buffer, FORMAT, SCALAR); \
output_add_string (BUFFER, (BUFFER)->digit_buffer); \
} \
while (0)
/* Forward declarations. */
typedef struct diagnostic_context diagnostic_context;
@ -179,10 +57,8 @@ typedef diagnostic_starter_fn diagnostic_finalizer_fn;
the context of a diagnostic message. */
struct diagnostic_context
{
/* Where most of the diagnostic formatting work is done. In Object
Oriented terms, we'll say that diagnostic_context is a sub-class of
output_buffer. */
output_buffer buffer;
/* Where most of the diagnostic formatting work is done. */
pretty_printer *printer;
/* The number of times we have issued diagnostics. */
int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND];
@ -233,15 +109,17 @@ struct diagnostic_context
/* Extension hook for client. */
#define diagnostic_auxiliary_data(DC) (DC)->x_data
/* Same as output_format_decoder. Works on 'diagnostic_context *'. */
#define diagnostic_format_decoder(DC) output_format_decoder (&(DC)->buffer)
/* Same as pp_format_decoder. Works on 'diagnostic_context *'. */
#define diagnostic_format_decoder(DC) pp_format_decoder ((DC)->printer)
/* Same as output_prefixing_rule. Works on 'diagnostic_context *'. */
#define diagnostic_prefixing_rule(DC) output_prefixing_rule (&(DC)->buffer)
#define diagnostic_prefixing_rule(DC) ((DC)->printer->prefixing_rule)
/* Maximum characters per line in automatic line wrapping mode.
Zero means don't wrap lines. */
#define diagnostic_line_cutoff(DC) output_line_cutoff (&(DC)->buffer)
#define diagnostic_line_cutoff(DC) ((DC)->printer->ideal_maximum_length)
#define diagnostic_flush_buffer(DC) pp_flush ((DC)->printer)
/* True if the last function in which a diagnostic was reported is
different from the current one. */
@ -294,7 +172,6 @@ extern diagnostic_context *global_dc;
extern void diagnostic_initialize (diagnostic_context *);
extern void diagnostic_report_current_module (diagnostic_context *);
extern void diagnostic_report_current_function (diagnostic_context *);
extern void diagnostic_flush_buffer (diagnostic_context *);
extern void diagnostic_report_diagnostic (diagnostic_context *,
diagnostic_info *);
extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
@ -302,27 +179,6 @@ extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
extern char *diagnostic_build_prefix (diagnostic_info *);
/* Pure text formatting support functions. */
extern void init_output_buffer (output_buffer *, const char *, int);
extern void output_clear (output_buffer *);
extern const char *output_last_position (const output_buffer *);
extern void output_set_prefix (output_buffer *, const char *);
extern void output_destroy_prefix (output_buffer *);
extern void output_set_maximum_length (output_buffer *, int);
extern void output_emit_prefix (output_buffer *);
extern void output_add_newline (output_buffer *);
extern void output_add_space (output_buffer *);
extern int output_space_left (const output_buffer *);
extern void output_append (output_buffer *, const char *, const char *);
extern void output_add_character (output_buffer *, int);
extern void output_decimal (output_buffer *, int);
extern void output_host_wide_integer (output_buffer *, HOST_WIDE_INT);
extern void output_add_string (output_buffer *, const char *);
extern void output_add_identifier (output_buffer *, tree);
extern const char *output_finalize_message (output_buffer *);
extern void output_clear_message_text (output_buffer *);
extern void output_printf (output_buffer *, const char *, ...)
ATTRIBUTE_PRINTF_2;
extern void output_verbatim (output_buffer *, const char *, ...);
extern void verbatim (const char *, ...);
extern char *file_name_as_prefix (const char *);

View File

@ -2036,9 +2036,9 @@ output_reg_number (rtx rtl)
if (regno >= DWARF_FRAME_REGISTERS)
{
warning_with_decl (dwarf_last_decl,
"internal regno botch: `%s' has regno = %d\n",
regno);
warning ("%Hinternal regno botch: '%D' has regno = %d\n",
&DECL_SOURCE_LOCATION (dwarf_last_decl), dwarf_last_decl,
regno);
regno = 0;
}
dw2_assemble_integer (4, GEN_INT (DBX_REGISTER_NUMBER (regno)));

View File

@ -6734,7 +6734,8 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode, enum expand_modifier
case PARM_DECL:
if (!DECL_RTL_SET_P (exp))
{
error_with_decl (exp, "prior parameter's size depends on `%s'");
error ("%Hprior parameter's size depends on '%D'",
&DECL_SOURCE_LOCATION (exp), exp);
return CONST0_RTX (mode);
}

View File

@ -877,7 +877,8 @@ assign_temp (tree type_or_decl, int keep, int memory_required,
if (decl && size == -1
&& TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST)
{
error_with_decl (decl, "size of variable `%s' is too large");
error ("%Hsize of variable '%D' is too large",
&DECL_SOURCE_LOCATION (decl), decl);
size = 1;
}
@ -5567,15 +5568,15 @@ uninitialized_vars_warning (tree block)
not worry that it may be a dangling pointer. */
&& DECL_INITIAL (decl) == NULL_TREE
&& regno_uninitialized (REGNO (DECL_RTL (decl))))
warning_with_decl (decl,
"`%s' might be used uninitialized in this function");
warning ("%H'%D' might be used uninitialized in this function",
&DECL_SOURCE_LOCATION (decl), decl);
if (extra_warnings
&& TREE_CODE (decl) == VAR_DECL
&& DECL_RTL (decl) != 0
&& GET_CODE (DECL_RTL (decl)) == REG
&& regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
warning_with_decl (decl,
"variable `%s' might be clobbered by `longjmp' or `vfork'");
warning ("%Hvariable '%D' might be clobbered by `longjmp' or `vfork'",
&DECL_SOURCE_LOCATION (decl), decl);
}
for (sub = BLOCK_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub))
uninitialized_vars_warning (sub);
@ -5593,8 +5594,8 @@ setjmp_args_warning (void)
if (DECL_RTL (decl) != 0
&& GET_CODE (DECL_RTL (decl)) == REG
&& regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
warning_with_decl (decl,
"argument `%s' might be clobbered by `longjmp' or `vfork'");
warning ("%Hargument '%D' might be clobbered by `longjmp' or `vfork'",
&DECL_SOURCE_LOCATION (decl), decl);
}
/* If this function call setjmp, put all vars into the stack
@ -6919,7 +6920,8 @@ expand_function_end (void)
decl; decl = TREE_CHAIN (decl))
if (! TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
&& DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl))
warning_with_decl (decl, "unused parameter `%s'");
warning ("%Hunused parameter '%D'",
&DECL_SOURCE_LOCATION (decl), decl);
}
/* Delete handlers for nonlocal gotos if nothing uses them. */

View File

@ -1071,7 +1071,7 @@ common_handle_option (size_t scode, const char *arg,
break;
case OPT_fmessage_length_:
output_set_maximum_length (&global_dc->buffer, value);
pp_set_line_maximum_length (global_dc->printer, value);
break;
case OPT_fmove_all_movables:

547
gcc/pretty-print.c Normal file
View File

@ -0,0 +1,547 @@
/* Various declarations for language-independent pretty-print subroutines.
Copyright (C) 2003 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include "config.h"
#undef FLOAT /* This is for hpux. They should change hpux. */
#undef FFS /* Some systems define this in param.h. */
#include "system.h"
#include "coretypes.h"
#include "pretty-print.h"
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
/* A pointer to the formatted diagnostic message. */
#define pp_formatted_text_data(PP) \
((const char *) obstack_base (&pp_base (PP)->buffer->obstack))
/* Format an integer given by va_arg (ARG, type-specifier T) where
type-specifier is a precision modifier as indicated by PREC. F is
a string used to construct the appropriate format-specifier. */
#define pp_integer_with_precision(PP, ARG, PREC, T, F) \
do \
switch (PREC) \
{ \
case 0: \
pp_scalar (PP, "%" F, va_arg (ARG, T)); \
break; \
\
case 1: \
pp_scalar (PP, "%l" F, va_arg (ARG, long T)); \
break; \
\
case 2: \
pp_scalar (PP, "%ll" F, va_arg (ARG, long long T)); \
break; \
\
default: \
break; \
} \
while (0)
/* Subroutine of pp_set_maximum_length. Set up PRETTY-PRINTER's
internal maximum characters per line. */
static void
pp_set_real_maximum_length (pretty_printer *pp)
{
/* If we're told not to wrap lines then do the obvious thing. In case
we'll emit prefix only once per message, it is appropriate
not to increase unnecessarily the line-length cut-off. */
if (!pp_is_wrapping_line (pp)
|| pp_prefixing_rule (pp) == DIAGNOSTICS_SHOW_PREFIX_ONCE
|| pp_prefixing_rule (pp) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
pp->maximum_length = pp_line_cutoff (pp);
else
{
int prefix_length = pp->prefix ? strlen (pp->prefix) : 0;
/* If the prefix is ridiculously too long, output at least
32 characters. */
if (pp_line_cutoff (pp) - prefix_length < 32)
pp->maximum_length = pp_line_cutoff (pp) + 32;
else
pp->maximum_length = pp_line_cutoff (pp);
}
}
/* Clear PRETTY-PRINTER's output state. */
static inline void
pp_clear_state (pretty_printer *pp)
{
pp->emitted_prefix = false;
pp_indentation (pp) = 0;
}
/* Insert enough spaces into the output area of PRETTY-PRINTER to bring
the column position to the current indentation level, assuming that a
newline has just been written to the buffer. */
static void
pp_indent (pretty_printer *pp)
{
int n = pp_indentation (pp);
int i;
for (i = 0; i < n; ++i)
pp_space (pp);
}
/* Flush the formatted text of PRETTY-PRINTER onto the attached stream. */
static inline void
pp_write_text_to_stream (pretty_printer *pp)
{
const char *text = pp_formatted_text (pp);
fputs (text, pp->buffer->stream);
pp_clear_output_area (pp);
}
/* Wrap a text delimited by START and END into PRETTY-PRINTER. */
static void
pp_wrap_text (pretty_printer *pp, const char *start, const char *end)
{
bool wrapping_line = pp_is_wrapping_line (pp);
while (start != end)
{
/* Dump anything bordered by whitespaces. */
{
const char *p = start;
while (p != end && !ISBLANK (*p) && *p != '\n')
++p;
if (wrapping_line
&& p - start >= pp_remaining_character_count_for_line (pp))
pp_newline (pp);
pp_append_text (pp, start, p);
start = p;
}
if (start != end && ISBLANK (*start))
{
pp_space (pp);
++start;
}
if (start != end && *start == '\n')
{
pp_newline (pp);
++start;
}
}
}
/* Same as pp_wrap_text but wrap text only when in line-wrapping mode. */
static inline void
pp_maybe_wrap_text (pretty_printer *pp, const char *start, const char *end)
{
if (pp_is_wrapping_line (pp))
pp_wrap_text (pp, start, end);
else
pp_append_text (pp, start, end);
}
/* Append to the output area of PRETTY-PRINTER a string specified by its
STARTing character and LENGTH. */
static inline void
pp_append_r (pretty_printer *pp, const char *start, int length)
{
obstack_grow (&pp->buffer->obstack, start, length);
pp->buffer->line_length += length;
}
/* Format a message pointed to by TEXT. The following format specifiers are
recognized as being client independent:
%d, %i: (signed) integer in base ten.
%u: unsigned integer in base ten.
%o: unsigned integer in base eight.
%x: unsigned integer in base sixteen.
%ld, %li, %lo, %lu, %lx: long versions of the above.
%lld, %lli, %llo, %llu, %llx: long long versions.
%wd, %wi, %wo, %wu, %wx: HOST_WIDE_INT versions.
%c: character.
%s: string.
%p: pointer.
%m: strerror(text->err_no) - does not consume a value from args_ptr.
%%: `%'.
%*.s: a substring the length of which is specified by an integer.
%H: location_t. */
void
pp_format_text (pretty_printer *pp, text_info *text)
{
for (; *text->format_spec; ++text->format_spec)
{
int precision = 0;
bool wide = false;
/* Ignore text. */
{
const char *p = text->format_spec;
while (*p && *p != '%')
++p;
pp_wrap_text (pp, text->format_spec, p);
text->format_spec = p;
}
if (*text->format_spec == '\0')
break;
/* We got a '%'. Parse precision modifiers, if any. */
switch (*++text->format_spec)
{
case 'w':
wide = true;
++text->format_spec;
break;
case 'l':
do
++precision;
while (*++text->format_spec == 'l');
break;
default:
break;
}
/* We don't support precision behond that of "long long". */
if (precision > 2)
abort();
switch (*text->format_spec)
{
case 'c':
pp_character (pp, va_arg (*text->args_ptr, int));
break;
case 'd':
case 'i':
if (wide)
pp_wide_integer (pp, va_arg (*text->args_ptr, HOST_WIDE_INT));
else
pp_integer_with_precision
(pp, *text->args_ptr, precision, int, "d");
break;
case 'o':
if (wide)
pp_scalar (pp, "%" HOST_WIDE_INT_PRINT "o",
va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
else
pp_integer_with_precision
(pp, *text->args_ptr, precision, unsigned, "u");
break;
case 's':
pp_string (pp, va_arg (*text->args_ptr, const char *));
break;
case 'p':
pp_pointer (pp, va_arg (*text->args_ptr, void *));
break;
case 'u':
if (wide)
pp_scalar (pp, HOST_WIDE_INT_PRINT_UNSIGNED,
va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
else
pp_integer_with_precision
(pp, *text->args_ptr, precision, unsigned, "u");
break;
case 'x':
if (wide)
pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX,
va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
else
pp_integer_with_precision
(pp, *text->args_ptr, precision, unsigned, "x");
break;
case 'm':
pp_string (pp, xstrerror (text->err_no));
break;
case '%':
pp_character (pp, '%');
break;
case 'H':
{
const location_t *locus = va_arg (*text->args_ptr, location_t *);
pp_string (pp, "file '");
pp_string (pp, locus->file);
pp_string (pp, "', line ");
pp_decimal_int (pp, locus->line);
}
break;
case '.':
{
int n;
const char *s;
/* We handle no precision specifier but `%.*s'. */
if (*++text->format_spec != '*')
abort ();
else if (*++text->format_spec != 's')
abort ();
n = va_arg (*text->args_ptr, int);
s = va_arg (*text->args_ptr, const char *);
pp_append_text (pp, s, s + n);
}
break;
default:
if (!pp_format_decoder (pp) || !(*pp_format_decoder (pp)) (pp, text))
{
/* Hmmm. The client failed to install a format translator
but called us with an unrecognized format. Or, maybe, the
translated string just contains an invalid format, or
has formats in the wrong order. Sorry. */
abort ();
}
}
}
}
/* Helper subroutine of output_verbatim and verbatim. Do the appropriate
settings needed by BUFFER for a verbatim formatting. */
void
pp_format_verbatim (pretty_printer *pp, text_info *text)
{
diagnostic_prefixing_rule_t rule = pp_prefixing_rule (pp);
int line_cutoff = pp_line_cutoff (pp);
/* Set verbatim mode. */
pp->prefixing_rule = DIAGNOSTICS_SHOW_PREFIX_NEVER;
pp_line_cutoff (pp) = 0;
/* Do the actual formatting. */
pp_format_text (pp, text);
/* Restore previous settings. */
pp_prefixing_rule (pp) = rule;
pp_line_cutoff (pp) = line_cutoff;
}
/* Flush the content of BUFFER onto the attached stream. */
void
pp_flush (pretty_printer *pp)
{
pp_write_text_to_stream (pp);
pp_clear_state (pp);
fputc ('\n', pp->buffer->stream);
fflush (pp->buffer->stream);
}
/* Sets the number of maximum characters per line PRETTY-PRINTER can
output in line-wrapping mode. A LENGTH value 0 suppresses
line-wrapping. */
void
pp_set_line_maximum_length (pretty_printer *pp, int length)
{
pp_line_cutoff (pp) = length;
pp_set_real_maximum_length (pp);
}
/* Clear PRETTY-PRINTER output area text info. */
void
pp_clear_output_area (pretty_printer *pp)
{
obstack_free (&pp->buffer->obstack, obstack_base (&pp->buffer->obstack));
pp->buffer->line_length = 0;
}
/* Set PREFIX for PRETTY-PRINTER. */
void
pp_set_prefix (pretty_printer *pp, const char *prefix)
{
pp->prefix = prefix;
pp_set_real_maximum_length (pp);
pp->emitted_prefix = false;
pp_indentation (pp) = 0;
}
/* Free PRETTY-PRINTER's prefix, a previously malloc()'d string. */
void
pp_destroy_prefix (pretty_printer *pp)
{
if (pp->prefix != NULL)
{
free ((char *) pp->prefix);
pp->prefix = NULL;
}
}
/* Write out PRETTY-PRINTER's prefix. */
void
pp_emit_prefix (pretty_printer *pp)
{
if (pp->prefix != NULL)
{
switch (pp_prefixing_rule (pp))
{
default:
case DIAGNOSTICS_SHOW_PREFIX_NEVER:
break;
case DIAGNOSTICS_SHOW_PREFIX_ONCE:
if (pp->emitted_prefix)
{
pp_indent (pp);
break;
}
pp_indentation (pp) += 3;
/* Fall through. */
case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
{
int prefix_length = strlen (pp->prefix);
pp_append_r (pp, pp->prefix, prefix_length);
pp->emitted_prefix = true;
}
break;
}
}
}
/* Construct a PRETTY-PRINTER with PREFIX and of MAXIMUM_LENGTH
characters per line. */
void
pp_construct (pretty_printer *pp, const char *prefix, int maximum_length)
{
memset (pp, 0, sizeof (pretty_printer));
pp->buffer = xmalloc (sizeof (output_buffer));
obstack_init (&pp->buffer->obstack);
pp->buffer->stream = stderr;
pp_line_cutoff (pp) = maximum_length;
pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
pp_set_prefix (pp, prefix);
}
/* Append a string delimited by START and END to the output area of
PRETTY-PRINTER. No line wrapping is done. However, if beginning a
new line then emit PRETTY-PRINTER's prefix and skip any leading
whitespace if appropriate. The caller must ensure that it is
safe to do so. */
void
pp_append_text (pretty_printer *pp, const char *start, const char *end)
{
/* Emit prefix and skip whitespace if we're starting a new line. */
if (pp->buffer->line_length == 0)
{
pp_emit_prefix (pp);
if (pp_is_wrapping_line (pp))
while (start != end && *start == ' ')
++start;
}
pp_append_r (pp, start, end - start);
}
/* Finishes constructing a NULL-terminated character string representing
the PRETTY-PRINTED text. */
const char *
pp_formatted_text (pretty_printer *pp)
{
obstack_1grow (&pp->buffer->obstack, '\0');
return pp_formatted_text_data (pp);
}
/* Return a pointer to the last character emitted in PRETTY-PRINTER's
output area. A NULL pointer means no character available. */
const char *
pp_last_position_in_text (const pretty_printer *pp)
{
const char *p = NULL;
struct obstack *text = &pp->buffer->obstack;
if (obstack_base (text) != obstack_next_free (text))
p = ((const char *) obstack_next_free (text)) - 1;
return p;
}
/* Return the amount of characters PRETTY-PRINTER can accept to
make a full line. Meaningfull only in line-wrapping mode. */
int
pp_remaining_character_count_for_line (pretty_printer *pp)
{
return pp->maximum_length - pp->buffer->line_length;
}
/* Format a message into BUFFER a la printf. */
void
pp_printf (pretty_printer *pp, const char *msg, ...)
{
text_info text;
va_list ap;
va_start (ap, msg);
text.err_no = errno;
text.args_ptr = &ap;
text.format_spec = msg;
pp_format_text (pp, &text);
va_end (ap);
}
/* Output MESSAGE verbatim into BUFFER. */
void
pp_verbatim (pretty_printer *pp, const char *msg, ...)
{
text_info text;
va_list ap;
va_start (ap, msg);
text.err_no = errno;
text.args_ptr = &ap;
text.format_spec = msg;
pp_format_verbatim (pp, &text);
va_end (ap);
}
/* Have PRETTY-PRINTER start a new line. */
void
pp_newline (pretty_printer *pp)
{
obstack_1grow (&pp->buffer->obstack, '\n');
pp->buffer->line_length = 0;
}
/* Have PRETTY-PRINTER add a CHARACTER. */
void
pp_character (pretty_printer *pp, int c)
{
if (pp_is_wrapping_line (pp)
&& pp_remaining_character_count_for_line (pp) <= 0)
{
pp_newline (pp);
if (ISSPACE (c))
return;
}
obstack_1grow (&pp->buffer->obstack, c);
++pp->buffer->line_length;
}
/* Append a STRING to the output area of PRETTY-PRINTER; the STRING may
be line-wrapped if in appropriate mode. */
void
pp_string (pretty_printer *pp, const char *str)
{
pp_maybe_wrap_text (pp, str, str + (str ? strlen (str) : 0));
}

View File

@ -1,5 +1,5 @@
/* Various declarations for language-independent pretty-print subroutines.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
This file is part of GCC.
@ -22,7 +22,47 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifndef GCC_PRETTY_PRINT_H
#define GCC_PRETTY_PRINT_H
#include "diagnostic.h"
#include "obstack.h"
#include "input.h"
/* The type of a text to be formatted according a format specification
along with a list of things. */
typedef struct
{
const char *format_spec;
va_list *args_ptr;
int err_no; /* for %m */
} text_info;
/* How often diagnostics are prefixed by their locations:
o DIAGNOSTICS_SHOW_PREFIX_NEVER: never - not yet supported;
o DIAGNOSTICS_SHOW_PREFIX_ONCE: emit only once;
o DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE: emit each time a physical
line is started. */
typedef enum
{
DIAGNOSTICS_SHOW_PREFIX_ONCE = 0x0,
DIAGNOSTICS_SHOW_PREFIX_NEVER = 0x1,
DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE = 0x2
} diagnostic_prefixing_rule_t;
/* The output buffer datatype. This is best seen as an abstract datatype
whose fields should not be accessed directly by clients. */
typedef struct
{
/* The obstack where the text is built up. */
struct obstack obstack;
/* Where to output formatted text. */
FILE *stream;
/* The amount of characters output so far. */
int line_length;
/* This must be large enough to hold any printed integer or
floating-point value. */
char digit_buffer[128];
} output_buffer;
/* The type of pretty-printer flags passed to clients. */
typedef unsigned int pp_flags;
@ -32,69 +72,163 @@ typedef enum
pp_none, pp_before, pp_after
} pp_padding;
/* The type of a hook that formats client-specific data onto a pretty_pinter.
A client-supplied formatter returns true if everything goes well,
otherwise it returns false. */
typedef struct pretty_print_info pretty_printer;
typedef bool (*printer_fn) (pretty_printer *, text_info *);
/* Client supplied function used to decode formats. */
#define pp_format_decoder(PP) pp_base (PP)->format_decoder
/* TRUE if a newline character needs to be added before further
formatting. */
#define pp_needs_newline(PP) pp_base (PP)->need_newline
/* Maximum characters per line in automatic line wrapping mode.
Zero means don't wrap lines. */
#define pp_line_cutoff(PP) pp_base (PP)->ideal_maximum_length
/* True if PRETTY-PTINTER is in line-wrapping mode. */
#define pp_is_wrapping_line(PP) (pp_line_cutoff (PP) > 0)
/* Prefixing rule used in formatting a diagnostic message. */
#define pp_prefixing_rule(PP) pp_base (PP)->prefixing_rule
/* The amount of whitespace to be emitted when starting a new line. */
#define pp_indentation(PP) pp_base (PP)->indent_skip
/* The data structure that contains the bare minimum required to do
proper pretty-printing. Clients may derived from this structure
and add additional fields they need. */
struct pretty_print_info
{
/* Where we print external representation of ENTITY. */
output_buffer *buffer;
/* The prefix for each new line. */
const char *prefix;
pp_flags flags;
/* Where to put whitespace around the entity being formatted. */
pp_padding padding;
/* The real upper bound of number of characters per line, taking into
account the case of a very very looong prefix. */
int maximum_length;
/* The ideal upper bound of number of characters per line, as suggested
by front-end. */
int ideal_maximum_length;
/* Indentation count. */
int indent_skip;
/* Current prefixing rule. */
diagnostic_prefixing_rule_t prefixing_rule;
/* If non-NULL, this function formats a TEXT into the BUFFER. When called,
TEXT->format_spec points to a format code. FORMAT_DECODER should call
pp_string (and related functions) to add data to the BUFFER.
FORMAT_DECODER can read arguments from *TEXT->args_pts using VA_ARG.
If the BUFFER needs additional characters from the format string, it
should advance the TEXT->format_spec as it goes. When FORMAT_DECODER
returns, TEXT->format_spec should point to the last character processed.
*/
printer_fn format_decoder;
/* Nonzero if current PREFIX was emitted at least once. */
bool emitted_prefix;
/* Nonzero means one should emit a newline before outputting anything. */
bool need_newline;
};
#define pp_left_paren(PPI) output_add_character (pp_buffer (PPI), '(')
#define pp_right_paren(PPI) output_add_character (pp_buffer (PPI), ')')
#define pp_left_bracket(PPI) output_add_character (pp_buffer (PPI), '[')
#define pp_right_bracket(PPI) output_add_character (pp_buffer (PPI), ']')
#define pp_left_brace(PPI) output_add_character (pp_buffer (PPI), '{')
#define pp_right_brace(PPI) output_add_character (pp_buffer (PPI), '}')
#define pp_semicolon(PPI) output_add_character (pp_buffer (PPI), ';')
#define pp_comma(PPI) output_add_string (pp_buffer (PPI), ", ")
#define pp_dot(PPI) output_add_character (pp_buffer (PPI), '.')
#define pp_colon(PPI) output_add_character (pp_buffer (PPI), ':')
#define pp_colon_colon(PPI) output_add_string (pp_buffer (PPI), "::")
#define pp_arrow(PPI) output_add_string (pp_buffer (PPI), "->")
#define pp_equal(PPI) output_add_character (pp_buffer (PPI), '=')
#define pp_question(PPI) output_add_character (pp_buffer (PPI), '?')
#define pp_bar(PPI) output_add_character (pp_buffer (PPI), '|')
#define pp_carret(PPI) output_add_character (pp_buffer (PPI), '^')
#define pp_ampersand(PPI) output_add_character (pp_buffer (PPI), '&')
#define pp_less(PPI) output_add_character (pp_buffer (PPI), '<')
#define pp_greater(PPI) output_add_character (pp_buffer (PPI), '>')
#define pp_plus(PPI) output_add_character (pp_buffer (PPI), '+')
#define pp_minus(PPI) output_add_character (pp_buffer (PPI), '-')
#define pp_star(PPI) output_add_character (pp_buffer (PPI), '*')
#define pp_slash(PPI) output_add_character (pp_buffer (PPI), '/')
#define pp_modulo(PPI) output_add_character (pp_buffer (PPI), '%')
#define pp_exclamation(PPI) output_add_character (pp_buffer (PPI), '!')
#define pp_complement(PPI) output_add_character (pp_buffer (PPI), '~')
#define pp_quote(PPI) output_add_character (pp_buffer (PPI), '\'')
#define pp_backquote(PPI) output_add_character (pp_buffer (PPI), '`')
#define pp_doublequote(PPI) output_add_character (pp_buffer (PPI), '"')
#define pp_newline(PPI) output_add_newline (pp_buffer (PPI))
#define pp_character(PPI, C) output_add_character (pp_buffer (PPI), C)
#define pp_whitespace(PPI) output_add_space (pp_buffer (PPI))
#define pp_indentation(PPI) output_indentation (pp_buffer (PPI))
#define pp_newline_and_indent(PPI, N) \
do { \
pp_indentation (PPI) += N; \
pp_newline (PPI); \
#define pp_space(PP) pp_character (pp_base (PP), ' ')
#define pp_left_paren(PP) pp_character (pp_base (PP), '(')
#define pp_right_paren(PP) pp_character (pp_base (PP), ')')
#define pp_left_bracket(PP) pp_character (pp_base (PP), '[')
#define pp_right_bracket(PP) pp_character (pp_base (PP), ']')
#define pp_left_brace(PP) pp_character (pp_base (PP), '{')
#define pp_right_brace(PP) pp_character (pp_base (PP), '}')
#define pp_semicolon(PP) pp_character (pp_base (PP), ';')
#define pp_comma(PP) pp_string (pp_base (PP), ", ")
#define pp_dot(PP) pp_character (pp_base (PP), '.')
#define pp_colon(PP) pp_character (pp_base (PP), ':')
#define pp_colon_colon(PP) pp_string (pp_base (PP), "::")
#define pp_arrow(PP) pp_string (pp_base (PP), "->")
#define pp_equal(PP) pp_character (pp_base (PP), '=')
#define pp_question(PP) pp_character (pp_base (PP), '?')
#define pp_bar(PP) pp_character (pp_base (PP), '|')
#define pp_carret(PP) pp_character (pp_base (PP), '^')
#define pp_ampersand(PP) pp_character (pp_base (PP), '&')
#define pp_less(PP) pp_character (pp_base (PP), '<')
#define pp_greater(PP) pp_character (pp_base (PP), '>')
#define pp_plus(PP) pp_character (pp_base (PP), '+')
#define pp_minus(PP) pp_character (pp_base (PP), '-')
#define pp_star(PP) pp_character (pp_base (PP), '*')
#define pp_slash(PP) pp_character (pp_base (PP), '/')
#define pp_modulo(PP) pp_character (pp_base (PP), '%')
#define pp_exclamation(PP) pp_character (pp_base (PP), '!')
#define pp_complement(PP) pp_character (pp_base (PP), '~')
#define pp_quote(PP) pp_character (pp_base (PP), '\'')
#define pp_backquote(PP) pp_character (pp_base (PP), '`')
#define pp_doublequote(PP) pp_character (pp_base (PP), '"')
#define pp_newline_and_indent(PP, N) \
do { \
pp_indentation (PP) += N; \
pp_newline (PP); \
} while (0)
#define pp_separate_with(PPI, C) \
do { \
pp_character (PPI, C); \
pp_whitespace (PPI); \
#define pp_separate_with(PP, C) \
do { \
pp_character (pp_base (PP), C);\
pp_space (PP); \
} while (0)
#define pp_format_scalar(PPI, F, S) \
output_formatted_scalar (pp_buffer (PPI), F, S)
#define pp_wide_integer(PPI, I) \
pp_format_scalar (PPI, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) I)
#define pp_pointer(PPI, P) pp_format_scalar (PPI, "%p", p)
#define pp_scalar(PP, FORMAT, SCALAR) \
do \
{ \
sprintf (pp_base (PP)->buffer->digit_buffer, FORMAT, SCALAR); \
pp_string (pp_base (PP), pp_base (PP)->buffer->digit_buffer); \
} \
while (0)
#define pp_decimal_int(PP, I) pp_scalar (PP, "%d", I)
#define pp_wide_integer(PP, I) \
pp_scalar (PP, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) I)
#define pp_pointer(PP, P) pp_scalar (PP, "%p", P)
#define pp_identifier(PPI, ID) output_add_string (pp_buffer (PPI), ID)
#define pp_tree_identifier(PPI, T) pp_identifier(PPI, IDENTIFIER_POINTER (T))
#define pp_identifier(PP, ID) pp_string (pp_base (PP), ID)
#define pp_tree_identifier(PP, T) \
pp_append_text(pp_base (PP), IDENTIFIER_POINTER (T), \
IDENTIFIER_POINTER (T) + IDENTIFIER_LENGTH (T))
#define pp_unsupported_tree(PPI, T) \
output_verbatim (pp_buffer(PPI), "#`%s' not supported by %s#",\
#define pp_unsupported_tree(PP, T) \
pp_verbatim (pp_base (PP), "#`%s' not supported by %s#",\
tree_code_name[(int) TREE_CODE (T)], __FUNCTION__)
/* Clients that directly derive from pretty_printer need to override
this macro to return a pointer to the base pretty_printer structrure. */
#define pp_base(PP) (PP)
extern void pp_construct (pretty_printer *, const char *, int);
extern void pp_set_line_maximum_length (pretty_printer *, int);
extern void pp_set_prefix (pretty_printer *, const char *);
extern void pp_destroy_prefix (pretty_printer *);
extern int pp_remaining_character_count_for_line (pretty_printer *);
extern void pp_clear_output_area (pretty_printer *);
extern const char *pp_formatted_text (pretty_printer *);
extern const char *pp_last_position_in_text (const pretty_printer *);
extern void pp_emit_prefix (pretty_printer *);
extern void pp_append_text (pretty_printer *, const char *, const char *);
extern void pp_printf (pretty_printer *, const char *, ...) ATTRIBUTE_PRINTF_2;
extern void pp_verbatim (pretty_printer *, const char *, ...);
extern void pp_flush (pretty_printer *);
extern void pp_format_text (pretty_printer *, text_info *);
extern void pp_format_verbatim (pretty_printer *, text_info *);
extern void pp_newline (pretty_printer *);
extern void pp_character (pretty_printer *, int);
extern void pp_string (pretty_printer *, const char *);
#endif /* GCC_PRETTY_PRINT_H */

View File

@ -986,8 +986,8 @@ fixup_gotos (struct nesting *thisblock, rtx stack_level,
&& INSN_UID (first_insn) > INSN_UID (f->before_jump)
&& ! DECL_ERROR_ISSUED (f->target))
{
error_with_decl (f->target,
"label `%s' used before containing binding contour");
error ("%Hlabel '%D' used before containing binding contour",
&DECL_SOURCE_LOCATION (f->target), f->target);
/* Prevent multiple errors for one label. */
DECL_ERROR_ISSUED (f->target) = 1;
}
@ -3636,7 +3636,7 @@ warn_about_unused_variables (tree vars)
&& ! TREE_USED (decl)
&& ! DECL_IN_SYSTEM_HEADER (decl)
&& DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl))
warning_with_decl (decl, "unused variable `%s'");
warning ("%Hunused variable '%D'", &DECL_SOURCE_LOCATION (decl), decl);
}
/* Generate RTL code to terminate a binding contour.
@ -3696,8 +3696,8 @@ expand_end_bindings (tree vars, int mark_ends, int dont_jump_in)
that must be an error, because gotos without fixups
come from outside all saved stack-levels. */
if (TREE_ADDRESSABLE (chain->label))
error_with_decl (chain->label,
"label `%s' used before containing binding contour");
error ("%Hlabel '%D' used before containing binding contour",
&DECL_SOURCE_LOCATION (chain->label), chain->label);
}
}

View File

@ -515,10 +515,11 @@ layout_decl (tree decl, unsigned int known_align)
int size_as_int = TREE_INT_CST_LOW (size);
if (compare_tree_int (size, size_as_int) == 0)
warning_with_decl (decl, "size of `%s' is %d bytes", size_as_int);
warning ("%Hsize of '%D' is %d bytes",
&DECL_SOURCE_LOCATION (decl), decl, size_as_int);
else
warning_with_decl (decl, "size of `%s' is larger than %d bytes",
larger_than_size);
warning ("size of '%D' is larger than %d bytes",
&DECL_SOURCE_LOCATION (decl), decl, larger_than_size);
}
}
@ -883,9 +884,11 @@ place_field (record_layout_info rli, tree field)
if (TYPE_ALIGN (type) > desired_align)
{
if (STRICT_ALIGNMENT)
warning_with_decl (field, "packed attribute causes inefficient alignment for `%s'");
warning ("%Hpacked attribute causes inefficient alignment "
"for '%D'", &DECL_SOURCE_LOCATION (field), field);
else
warning_with_decl (field, "packed attribute is unnecessary for `%s'");
warning ("%Hpacked attribute is unnecessary for '%D'",
&DECL_SOURCE_LOCATION (field), field);
}
}
else
@ -900,7 +903,8 @@ place_field (record_layout_info rli, tree field)
Bump the cumulative size to multiple of field alignment. */
if (warn_padded)
warning_with_decl (field, "padding struct to align `%s'");
warning ("%Hpadding struct to align '%D'",
&DECL_SOURCE_LOCATION (field), field);
/* If the alignment is still within offset_align, just align
the bit position. */

View File

@ -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)
: "<anonymous>";
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 ();

View File

@ -56,10 +56,10 @@ extern void _fatal_insn (const char *, rtx, const char *, int, const char *)
extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
ATTRIBUTE_NORETURN;
extern void warning (const char *, ...);
extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void error (const char *, ...);
extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
ATTRIBUTE_NORETURN;
extern void pedwarn (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void pedwarn (const char *, ...);
extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
@ -67,10 +67,6 @@ extern void rest_of_decl_compilation (tree, const char *, int, int);
extern void rest_of_type_compilation (tree, int);
extern void rest_of_compilation (tree);
extern void pedwarn_with_decl (tree, const char *, ...);
extern void warning_with_decl (tree, const char *, ...);
extern void error_with_decl (tree, const char *, ...);
extern void announce_function (tree);
extern void error_for_asm (rtx, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);

View File

@ -1171,7 +1171,8 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data)
if (warn_inline && DECL_INLINE (fn) && !DID_INLINE_FUNC (fn)
&& !DECL_IN_SYSTEM_HEADER (fn))
{
warning_with_decl (fn, "inlining failed in call to `%s'");
warning ("%Hinlining failed in call to '%F'",
&DECL_SOURCE_LOCATION (fn), fn);
warning ("called from here");
}
return NULL_TREE;

View File

@ -432,7 +432,8 @@ named_section (tree decl, const char *name, int reloc)
{
flags = get_named_section_flags (name);
if ((flags & SECTION_OVERRIDE) == 0)
error_with_decl (decl, "%s causes a section type conflict");
error ("%H%D causes a section type conflict",
&DECL_SOURCE_LOCATION (decl), decl);
}
named_section_flags (name, flags);
@ -802,15 +803,17 @@ make_decl_rtl (tree decl, const char *asmspec)
{
/* First detect errors in declaring global registers. */
if (reg_number == -1)
error_with_decl (decl, "register name not specified for `%s'");
error ("%Hregister name not specified for '%D'",
&DECL_SOURCE_LOCATION (decl), decl);
else if (reg_number < 0)
error_with_decl (decl, "invalid register name for `%s'");
error ("%Hinvalid register name for '%D'",
&DECL_SOURCE_LOCATION (decl), decl);
else if (TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
error_with_decl (decl,
"data type of `%s' isn't suitable for a register");
error ("%Hdata type of '%D' isn't suitable for a register",
&DECL_SOURCE_LOCATION (decl), decl);
else if (! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl))))
error_with_decl (decl,
"register specified for `%s' isn't suitable for data type");
error ("%Hregister specified for '%D' isn't suitable for data type",
&DECL_SOURCE_LOCATION (decl), decl);
/* Now handle properly declared static register variables. */
else
{
@ -854,8 +857,8 @@ make_decl_rtl (tree decl, const char *asmspec)
Also handle vars declared register invalidly. */
if (reg_number >= 0 || reg_number == -3)
error_with_decl (decl,
"register name given for non-register variable `%s'");
error ("%Hregister name given for non-register variable '%D'",
&DECL_SOURCE_LOCATION (decl), decl);
/* Specifying a section attribute on a variable forces it into a
non-.bss section, and thus it cannot be common. */
@ -1391,7 +1394,8 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
if (! dont_output_data
&& ! host_integerp (DECL_SIZE_UNIT (decl), 1))
{
error_with_decl (decl, "size of variable `%s' is too large");
error ("%Hsize of variable '%D' is too large",
&DECL_SOURCE_LOCATION (decl), decl);
return;
}
@ -1429,9 +1433,9 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
#endif
if (align > MAX_OFILE_ALIGNMENT)
{
warning_with_decl (decl,
"alignment of `%s' is greater than maximum object file alignment. Using %d",
MAX_OFILE_ALIGNMENT/BITS_PER_UNIT);
warning ("%Halignment of '%D' is greater than maximum object "
"file alignment. Using %d", &DECL_SOURCE_LOCATION (decl),
decl, MAX_OFILE_ALIGNMENT/BITS_PER_UNIT);
align = MAX_OFILE_ALIGNMENT;
}
@ -1497,8 +1501,9 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
#if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_DECL_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
if ((unsigned HOST_WIDE_INT) DECL_ALIGN (decl) / BITS_PER_UNIT > rounded)
warning_with_decl
(decl, "requested alignment for %s is greater than implemented alignment of %d",rounded);
warning ("%Hrequested alignment for '%D' is greater than "
"implemented alignment of %d", &DECL_SOURCE_LOCATION (decl),
decl, rounded);
#endif
/* If the target cannot output uninitialized but not common global data
@ -4169,15 +4174,17 @@ merge_weak (tree newdecl, tree olddecl)
declare_weak because the NEWDECL and OLDDECL was not yet
been merged; therefore, TREE_ASM_WRITTEN was not set. */
if (TREE_ASM_WRITTEN (olddecl))
error_with_decl (newdecl,
"weak declaration of `%s' must precede definition");
error ("%Hweak declaration of '%D' must precede definition",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
/* If we've already generated rtl referencing OLDDECL, we may
have done so in a way that will not function properly with
a weak symbol. */
else if (TREE_USED (olddecl)
&& TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)))
warning_with_decl (newdecl, "weak declaration of `%s' after first use results in unspecified behavior");
warning ("%Hweak declaration of '%D' after first use results "
"in unspecified behavior",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
if (SUPPORTS_WEAK)
{
@ -4210,16 +4217,19 @@ void
declare_weak (tree decl)
{
if (! TREE_PUBLIC (decl))
error_with_decl (decl, "weak declaration of `%s' must be public");
error ("%Hweak declaration of '%D' must be public",
&DECL_SOURCE_LOCATION (decl), decl);
else if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl))
error_with_decl (decl, "weak declaration of `%s' must precede definition");
error ("%Hweak declaration of '%D' must precede definition",
&DECL_SOURCE_LOCATION (decl), decl);
else if (SUPPORTS_WEAK)
{
if (! DECL_WEAK (decl))
weak_decls = tree_cons (NULL, decl, weak_decls);
}
else
warning_with_decl (decl, "weak declaration of `%s' not supported");
warning ("%Hweak declaration of '%D' not supported",
&DECL_SOURCE_LOCATION (decl), decl);
mark_weak (decl);
}