This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[mainline] PATCH: Bye bye {pedwarn, warning, error}_with_decl
- From: gdr at integrable-solutions dot net
- To: gcc-patches at gcc dot gnu dot org
- Date: 25 Jul 2003 12:06:48 +0200
- Subject: [mainline] PATCH: Bye bye {pedwarn, warning, error}_with_decl
- Organization: Integrable Solutions
This patch basically removes pedwarn_with_decl, warnin_with_decl and
error_with_decl definitely from GCC.
Previous works removed them from the front-ends. This patch removes
the remaining uses from the middle-end. I then discorered that the
previous categorization of diagnostic format into three groups was
incomplete: There is a fourth group, mainly the set of format
specifiers used by the middle end. It it almost __gcc_diag__ except
that 'D' may be used. That sort will be taken care of in later
patches.
Another side effect of this patch is that now, we have purelly
formatting, non-diagnostic relating routines are moved into a separate
file (something requested by Sebastian Pop at leats a year ago).
You may start reuseing them in other parts of GCC. There are work
left for making diagnostic.c self contained. To be taken care of in
future patches.
This patch also makes it possible to share code in pretty-printing
ASTs in the C and C++ front ends, something that would be also useful
for the tree-ssa branch. Work to be completed in future patches.
Bootstrapped and tested on an i686-pc-linux-gnu.
-- Gaby
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.
cp/
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.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1123
diff -p -r1.1123 Makefile.in
*** Makefile.in 24 Jul 2003 14:32:10 -0000 1.1123
--- Makefile.in 25 Jul 2003 09:44:35 -0000
*************** C_TREE_H = c-tree.h $(C_COMMON_H)
*** 652,657 ****
--- 652,659 ----
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
*************** OBJS-common = \
*** 821,827 ****
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)
OBJS-md = $(out_object_file)
OBJS-archive = $(EXTRA_OBJS) $(host_hook_obj) hashtable.o tree-inline.o \
--- 823,829 ----
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 pretty-print.o $(GGC)
OBJS-md = $(out_object_file)
OBJS-archive = $(EXTRA_OBJS) $(host_hook_obj) hashtable.o tree-inline.o \
*************** s-crt0: $(CRT0_S) $(MCRT0_S) $(GCC_PASSE
*** 1238,1244 ****
# 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-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
--- 1240,1246 ----
# 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-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
*************** c-ppoutput.o : c-ppoutput.c $(CONFIG_H)
*** 1282,1288 ****
$(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) \
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
--- 1284,1290 ----
$(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) \
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
*************** tlink.o: tlink.c $(DEMANGLE_H) $(HASHTAB
*** 1317,1329 ****
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)
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 \
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@
--- 1319,1331 ----
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)
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) \
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@
*************** attribs.o : attribs.c $(CONFIG_H) $(SYST
*** 1339,1345 ****
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-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) \
--- 1341,1347 ----
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-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) \
*************** stor-layout.o : stor-layout.c $(CONFIG_H
*** 1473,1486 ****
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 \
$(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
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 \
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) \
--- 1475,1488 ----
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 \
$(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
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) \
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) \
*************** host-default.o : host-default.c $(CONFIG
*** 1496,1502 ****
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)
rtl.o : rtl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(RTL_H) real.h \
$(GGC_H) errors.h
--- 1498,1504 ----
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)
rtl.o : rtl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(RTL_H) real.h \
$(GGC_H) errors.h
*************** dwarfout.o : dwarfout.c $(CONFIG_H) $(SY
*** 1563,1569 ****
$(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 \
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)
--- 1565,1571 ----
$(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 \
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)
*************** integrate.o : integrate.c $(CONFIG_H) $(
*** 1585,1591 ****
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
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 \
--- 1587,1593 ----
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)
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 \
*************** ifcvt.o : ifcvt.c $(CONFIG_H) $(SYSTEM_H
*** 1794,1799 ****
--- 1796,1802 ----
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 \
Index: c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.29
diff -p -r1.29 c-objc-common.c
*** c-objc-common.c 18 Jul 2003 23:05:53 -0000 1.29
--- c-objc-common.c 25 Jul 2003 09:44:36 -0000
*************** Software Foundation, 59 Temple Place - S
*** 39,45 ****
#include "target.h"
#include "cgraph.h"
! static bool c_tree_printer (output_buffer *, text_info *);
static tree inline_forbidden_p (tree *, int *, void *);
static void expand_deferred_fns (void);
static tree start_cdtor (int);
--- 39,45 ----
#include "target.h"
#include "cgraph.h"
! 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);
*************** c_objc_common_finish_file (void)
*** 416,422 ****
Please notice when called, the `%' part was already skipped by the
diagnostic machinery. */
static bool
! c_tree_printer (output_buffer *buffer, text_info *text)
{
tree t = va_arg (*text->args_ptr, tree);
--- 416,422 ----
Please notice when called, the `%' part was already skipped by the
diagnostic machinery. */
static bool
! c_tree_printer (pretty_printer *pp, text_info *text)
{
tree t = va_arg (*text->args_ptr, tree);
*************** c_tree_printer (output_buffer *buffer, t
*** 429,442 ****
const char *n = DECL_NAME (t)
? (*lang_hooks.decl_printable_name) (t, 2)
: "({anonymous})";
! output_add_string (buffer, n);
}
return true;
case 'E':
if (TREE_CODE (t) == IDENTIFIER_NODE)
{
! output_add_string (buffer, IDENTIFIER_POINTER (t));
return true;
}
return false;
--- 429,442 ----
const char *n = DECL_NAME (t)
? (*lang_hooks.decl_printable_name) (t, 2)
: "({anonymous})";
! pp_string (pp, n);
}
return true;
case 'E':
if (TREE_CODE (t) == IDENTIFIER_NODE)
{
! pp_string (pp, IDENTIFIER_POINTER (t));
return true;
}
return false;
Index: c-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pretty-print.c,v
retrieving revision 1.18
diff -p -r1.18 c-pretty-print.c
*** c-pretty-print.c 14 Jul 2003 20:52:04 -0000 1.18
--- c-pretty-print.c 25 Jul 2003 09:44:36 -0000
*************** static void pp_c_type_id (c_pretty_print
*** 74,79 ****
--- 74,82 ----
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. */
*************** pp_c_init_declarator (c_pretty_printer p
*** 248,256 ****
pp_declarator (pp, t);
if (DECL_INITIAL (t))
{
! pp_whitespace (pp);
pp_equal (pp);
! pp_whitespace (pp);
pp_c_initializer (pp, DECL_INITIAL (t));
}
}
--- 251,259 ----
pp_declarator (pp, t);
if (DECL_INITIAL (t))
{
! pp_space (pp);
pp_equal (pp);
! pp_space (pp);
pp_c_initializer (pp, DECL_INITIAL (t));
}
}
*************** pp_c_char (c_pretty_printer ppi, int c)
*** 336,344 ****
break;
default:
if (ISPRINT (c))
! pp_character (ppi, c);
else
! pp_format_scalar (ppi, "\\%03o", (unsigned) c);
break;
}
}
--- 339,347 ----
break;
default:
if (ISPRINT (c))
! pp_character (&ppi->base, c);
else
! pp_scalar (ppi, "\\%03o", (unsigned) c);
break;
}
}
*************** pp_c_assignment_expression (c_pretty_pri
*** 1038,1044 ****
pp_c_unary_expression (ppi, TREE_OPERAND (e, 0));
pp_c_maybe_whitespace (ppi);
pp_equal (ppi);
! pp_whitespace (ppi);
pp_c_assignment_expression (ppi, TREE_OPERAND (e, 1));
}
else
--- 1041,1047 ----
pp_c_unary_expression (ppi, TREE_OPERAND (e, 0));
pp_c_maybe_whitespace (ppi);
pp_equal (ppi);
! pp_space (ppi);
pp_c_assignment_expression (ppi, TREE_OPERAND (e, 1));
}
else
*************** pp_c_statement (c_pretty_printer ppi, tr
*** 1234,1240 ****
case IF_STMT:
pp_c_identifier (ppi, "if");
! pp_whitespace (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, IF_COND (stmt));
pp_right_paren (ppi);
--- 1237,1243 ----
case IF_STMT:
pp_c_identifier (ppi, "if");
! pp_space (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, IF_COND (stmt));
pp_right_paren (ppi);
*************** pp_c_statement (c_pretty_printer ppi, tr
*** 1258,1264 ****
case SWITCH_STMT:
pp_newline (ppi);
pp_c_identifier (ppi, "switch");
! pp_whitespace (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, SWITCH_COND (stmt));
pp_right_paren (ppi);
--- 1261,1267 ----
case SWITCH_STMT:
pp_newline (ppi);
pp_c_identifier (ppi, "switch");
! pp_space (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, SWITCH_COND (stmt));
pp_right_paren (ppi);
*************** pp_c_statement (c_pretty_printer ppi, tr
*** 1269,1275 ****
case WHILE_STMT:
pp_c_identifier (ppi, "while");
! pp_whitespace (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, WHILE_COND (stmt));
pp_right_paren (ppi);
--- 1272,1278 ----
case WHILE_STMT:
pp_c_identifier (ppi, "while");
! pp_space (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, WHILE_COND (stmt));
pp_right_paren (ppi);
*************** pp_c_statement (c_pretty_printer ppi, tr
*** 1284,1290 ****
pp_statement (ppi, DO_BODY (stmt));
pp_newline_and_indent (ppi, -3);
pp_c_identifier (ppi, "while");
! pp_whitespace (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, DO_COND (stmt));
pp_c_right_paren (ppi);
--- 1287,1293 ----
pp_statement (ppi, DO_BODY (stmt));
pp_newline_and_indent (ppi, -3);
pp_c_identifier (ppi, "while");
! pp_space (ppi);
pp_c_left_paren (ppi);
pp_c_expression (ppi, DO_COND (stmt));
pp_c_right_paren (ppi);
*************** pp_c_statement (c_pretty_printer ppi, tr
*** 1294,1300 ****
case FOR_STMT:
pp_c_identifier (ppi, "for");
! pp_whitespace (ppi);
pp_c_left_paren (ppi);
pp_statement (ppi, FOR_INIT_STMT (stmt));
pp_c_whitespace (ppi);
--- 1297,1303 ----
case FOR_STMT:
pp_c_identifier (ppi, "for");
! pp_space (ppi);
pp_c_left_paren (ppi);
pp_statement (ppi, FOR_INIT_STMT (stmt));
pp_c_whitespace (ppi);
*************** pp_c_statement (c_pretty_printer ppi, tr
*** 1364,1383 ****
pp_c_identifier (ppi, is_extended ? "__asm__" : "asm");
if (has_volatile_p)
pp_c_identifier (ppi, "__volatile__");
! pp_whitespace (ppi);
pp_c_left_paren (ppi);
pp_c_string_literal (ppi, ASM_STRING (stmt));
if (is_extended)
{
! pp_whitespace (ppi);
pp_separate_with (ppi, ':');
if (ASM_OUTPUTS (stmt))
pp_c_expression (ppi, ASM_OUTPUTS (stmt));
! pp_whitespace (ppi);
pp_separate_with (ppi, ':');
if (ASM_INPUTS (stmt))
pp_c_expression (ppi, ASM_INPUTS (stmt));
! pp_whitespace (ppi);
pp_separate_with (ppi, ':');
if (ASM_CLOBBERS (stmt))
pp_c_expression (ppi, ASM_CLOBBERS (stmt));
--- 1367,1386 ----
pp_c_identifier (ppi, is_extended ? "__asm__" : "asm");
if (has_volatile_p)
pp_c_identifier (ppi, "__volatile__");
! pp_space (ppi);
pp_c_left_paren (ppi);
pp_c_string_literal (ppi, ASM_STRING (stmt));
if (is_extended)
{
! pp_space (ppi);
pp_separate_with (ppi, ':');
if (ASM_OUTPUTS (stmt))
pp_c_expression (ppi, ASM_OUTPUTS (stmt));
! pp_space (ppi);
pp_separate_with (ppi, ':');
if (ASM_INPUTS (stmt))
pp_c_expression (ppi, ASM_INPUTS (stmt));
! pp_space (ppi);
pp_separate_with (ppi, ':');
if (ASM_CLOBBERS (stmt))
pp_c_expression (ppi, ASM_CLOBBERS (stmt));
*************** pp_c_statement (c_pretty_printer ppi, tr
*** 1389,1395 ****
case FILE_STMT:
pp_c_identifier (ppi, "__FILE__");
! pp_whitespace (ppi);
pp_equal (ppi);
pp_c_whitespace (ppi);
pp_c_identifier (ppi, FILE_STMT_FILENAME (stmt));
--- 1392,1398 ----
case FILE_STMT:
pp_c_identifier (ppi, "__FILE__");
! pp_space (ppi);
pp_equal (ppi);
pp_c_whitespace (ppi);
pp_c_identifier (ppi, FILE_STMT_FILENAME (stmt));
Index: c-pretty-print.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pretty-print.h,v
retrieving revision 1.8
diff -p -r1.8 c-pretty-print.h
*** c-pretty-print.h 22 Jun 2003 13:41:24 -0000 1.8
--- c-pretty-print.h 25 Jul 2003 09:44:36 -0000
*************** struct c_pretty_print_info
*** 62,67 ****
--- 62,70 ----
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); \
*************** struct c_pretty_print_info
*** 84,90 ****
} while (0)
#define pp_c_whitespace(PPI) \
do { \
! pp_whitespace (PPI); \
pp_c_base (PPI)->base.padding = pp_none; \
} while (0)
#define pp_c_maybe_whitespace(PPI) \
--- 87,93 ----
} while (0)
#define pp_c_whitespace(PPI) \
do { \
! pp_space (PPI); \
pp_c_base (PPI)->base.padding = pp_none; \
} while (0)
#define pp_c_maybe_whitespace(PPI) \
*************** struct c_pretty_print_info
*** 101,110 ****
#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)
--- 104,109 ----
Index: calls.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/calls.c,v
retrieving revision 1.289
diff -p -r1.289 calls.c
*** calls.c 19 Jul 2003 14:47:00 -0000 1.289
--- calls.c 25 Jul 2003 09:44:38 -0000
*************** try_to_integrate (tree fndecl, tree actp
*** 1808,1814 ****
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 ("called from here");
}
(*lang_hooks.mark_addressable) (fndecl);
--- 1808,1815 ----
if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
&& optimize > 0 && !TREE_ADDRESSABLE (fndecl))
{
! warning ("%Hinlining failed in call to '%F'",
! &DECL_SOURCE_LOCATION (fndecl), fndecl);
warning ("called from here");
}
(*lang_hooks.mark_addressable) (fndecl);
*************** expand_call (tree exp, rtx target, int i
*** 2147,2153 ****
if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
&& optimize > 0)
{
! warning_with_decl (fndecl, "can't inline call to `%s'");
warning ("called from here");
}
(*lang_hooks.mark_addressable) (fndecl);
--- 2148,2155 ----
if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
&& optimize > 0)
{
! warning ("%Hcan't inline call to '%F'",
! &DECL_SOURCE_LOCATION (fndecl), fndecl);
warning ("called from here");
}
(*lang_hooks.mark_addressable) (fndecl);
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.c,v
retrieving revision 1.126
diff -p -r1.126 diagnostic.c
*** diagnostic.c 22 Jul 2003 23:15:25 -0000 1.126
--- diagnostic.c 25 Jul 2003 09:44:39 -0000
*************** Software Foundation, 59 Temple Place - S
*** 39,94 ****
#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 void default_diagnostic_starter (diagnostic_context *,
diagnostic_info *);
--- 39,47 ----
#include "langhooks.h"
#include "langhooks-def.h"
/* Prototypes. */
! static char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1;
static void default_diagnostic_starter (diagnostic_context *,
diagnostic_info *);
*************** with preprocessed source if appropriate.
*** 116,597 ****
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 *
--- 69,74 ----
*************** file_name_as_prefix (const char *f)
*** 614,740 ****
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 = ≈
- 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 = ≈
- 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);
!
/* By default, diagnostics are sent to stderr. */
! output_buffer_attached_stream (&context->buffer) = stderr;
!
/* By default, we emit prefixes once per message. */
! diagnostic_prefixing_rule (context) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
diagnostic_starter (context) = default_diagnostic_starter;
diagnostic_finalizer (context) = default_diagnostic_finalizer;
! context->warnings_are_errors_message = warnings_are_errors;
}
/* Returns true if the next format specifier in TEXT is a format specifier
--- 91,121 ----
return build_message_string ("%s: ", f);
}
/* Initialize the diagnostic message outputting machinery. */
void
diagnostic_initialize (diagnostic_context *context)
{
! /* 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. */
! context->printer->buffer->stream = stderr;
/* By default, we emit prefixes once per message. */
! 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->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
*************** diagnostic_build_prefix (diagnostic_info
*** 797,809 ****
_(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,
--- 178,183 ----
*************** diagnostic_count_diagnostic (diagnostic_
*** 852,859 ****
if (context->warnings_are_errors_message)
{
! output_verbatim (&context->buffer,
! "%s: warnings being treated as errors\n", progname);
context->warnings_are_errors_message = false;
}
--- 226,233 ----
if (context->warnings_are_errors_message)
{
! pp_verbatim (context->printer,
! "%s: warnings being treated as errors\n", progname);
context->warnings_are_errors_message = false;
}
*************** announce_function (tree decl)
*** 917,923 ****
else
verbatim (" %s", (*lang_hooks.decl_printable_name) (decl, 2));
fflush (stderr);
! output_needs_newline (&global_dc->buffer) = true;
diagnostic_set_last_function (global_dc);
}
}
--- 291,297 ----
else
verbatim (" %s", (*lang_hooks.decl_printable_name) (decl, 2));
fflush (stderr);
! global_dc->printer->need_newline = true;
diagnostic_set_last_function (global_dc);
}
}
*************** lhd_print_error_function (diagnostic_con
*** 929,957 ****
{
if (diagnostic_last_function_changed (context))
{
! const char *old_prefix = output_prefix (&context->buffer);
char *new_prefix = file ? build_message_string ("%s: ", file) : NULL;
! output_set_prefix (&context->buffer, new_prefix);
if (current_function_decl == NULL)
! output_add_string (&context->buffer, _("At top level:"));
else
{
if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
! output_printf
! (&context->buffer, "In member function `%s':",
(*lang_hooks.decl_printable_name) (current_function_decl, 2));
else
! output_printf
! (&context->buffer, "In function `%s':",
(*lang_hooks.decl_printable_name) (current_function_decl, 2));
}
! output_add_newline (&context->buffer);
diagnostic_set_last_function (context);
! output_buffer_to_stream (&context->buffer);
! context->buffer.state.prefix = old_prefix;
free ((char*) new_prefix);
}
}
--- 303,331 ----
{
if (diagnostic_last_function_changed (context))
{
! const char *old_prefix = context->printer->prefix;
char *new_prefix = file ? build_message_string ("%s: ", file) : NULL;
! pp_set_prefix (context->printer, new_prefix);
if (current_function_decl == NULL)
! pp_string (context->printer, _("At top level:"));
else
{
if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
! pp_printf
! (context->printer, "In member function `%s':",
(*lang_hooks.decl_printable_name) (current_function_decl, 2));
else
! pp_printf
! (context->printer, "In function `%s':",
(*lang_hooks.decl_printable_name) (current_function_decl, 2));
}
! pp_newline (context->printer);
diagnostic_set_last_function (context);
! pp_flush (context->printer);
! context->printer->prefix = old_prefix;
free ((char*) new_prefix);
}
}
*************** diagnostic_report_current_module (diagno
*** 972,994 ****
{
struct file_stack *p;
! if (output_needs_newline (&context->buffer))
{
! output_add_newline (&context->buffer);
! output_needs_newline (&context->buffer) = 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);
while ((p = p->next) != NULL)
! output_verbatim (&context->buffer,
! ",\n from %s:%d",
! p->location.file, p->location.line);
! output_verbatim (&context->buffer, ":\n");
diagnostic_set_last_module (context);
}
}
--- 346,368 ----
{
struct file_stack *p;
! if (pp_needs_newline (context->printer))
{
! pp_newline (context->printer);
! pp_needs_newline (context->printer) = false;
}
if (input_file_stack && diagnostic_last_module_changed (context))
{
p = input_file_stack;
! pp_verbatim (context->printer,
! "In file included from %s:%d",
! p->location.file, p->location.line);
while ((p = p->next) != NULL)
! pp_verbatim (context->printer,
! ",\n from %s:%d",
! p->location.file, p->location.line);
! pp_verbatim (context->printer, ":\n");
diagnostic_set_last_module (context);
}
}
*************** default_diagnostic_starter (diagnostic_c
*** 998,1011 ****
diagnostic_info *diagnostic)
{
diagnostic_report_current_function (context);
! output_set_prefix (&context->buffer, diagnostic_build_prefix (diagnostic));
}
static void
default_diagnostic_finalizer (diagnostic_context *context,
diagnostic_info *diagnostic __attribute__((unused)))
{
! output_destroy_prefix (&context->buffer);
}
/* Report a diagnostic message (an error or a warning) as specified by
--- 372,385 ----
diagnostic_info *diagnostic)
{
diagnostic_report_current_function (context);
! pp_set_prefix (context->printer, diagnostic_build_prefix (diagnostic));
}
static void
default_diagnostic_finalizer (diagnostic_context *context,
diagnostic_info *diagnostic __attribute__((unused)))
{
! pp_destroy_prefix (context->printer);
}
/* Report a diagnostic message (an error or a warning) as specified by
*************** diagnostic_report_diagnostic (diagnostic
*** 1024,1054 ****
if (diagnostic_count_diagnostic (context, diagnostic))
{
(*diagnostic_starter (context)) (context, diagnostic);
! output_format (&context->buffer, &diagnostic->message);
(*diagnostic_finalizer (context)) (context, diagnostic);
! output_flush (&context->buffer);
! diagnostic_action_after_output (context, diagnostic);
! }
!
! 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);
diagnostic_action_after_output (context, diagnostic);
}
--- 398,406 ----
if (diagnostic_count_diagnostic (context, diagnostic))
{
(*diagnostic_starter (context)) (context, diagnostic);
! pp_format_text (context->printer, &diagnostic->message);
(*diagnostic_finalizer (context)) (context, diagnostic);
! pp_flush (context->printer);
diagnostic_action_after_output (context, diagnostic);
}
*************** verbatim (const char *msgid, ...)
*** 1114,1121 ****
text.err_no = errno;
text.args_ptr = ≈
text.format_spec = _(msgid);
! output_do_verbatim (&global_dc->buffer, &text);
! output_buffer_to_stream (&global_dc->buffer);
va_end (ap);
}
--- 466,473 ----
text.err_no = errno;
text.args_ptr = ≈
text.format_spec = _(msgid);
! pp_format_verbatim (global_dc->printer, &text);
! pp_flush (global_dc->printer);
va_end (ap);
}
*************** internal_error (const char *msgid, ...)
*** 1234,1294 ****
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. */
--- 586,591 ----
*************** static void
*** 1351,1357 ****
error_recursion (diagnostic_context *context)
{
if (context->lock < 3)
! output_flush (&context->buffer);
fnotice (stderr,
"Internal compiler error: Error reporting routines re-entered.\n");
--- 648,654 ----
error_recursion (diagnostic_context *context)
{
if (context->lock < 3)
! pp_flush (context->printer);
fnotice (stderr,
"Internal compiler error: Error reporting routines re-entered.\n");
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.h,v
retrieving revision 1.63
diff -p -r1.63 diagnostic.h
*** diagnostic.h 5 Jul 2003 15:17:26 -0000 1.63
--- diagnostic.h 25 Jul 2003 09:44:39 -0000
*************** Software Foundation, 59 Temple Place - S
*** 22,38 ****
#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;
/* Constants used to discriminate diagnostics. */
typedef enum
--- 22,28 ----
#ifndef GCC_DIAGNOSTIC_H
#define GCC_DIAGNOSTIC_H
! #include "pretty-print.h"
/* Constants used to discriminate diagnostics. */
typedef enum
*************** typedef struct
*** 56,173 ****
#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;
--- 46,51 ----
*************** typedef diagnostic_starter_fn diagnostic
*** 179,188 ****
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;
/* The number of times we have issued diagnostics. */
int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND];
--- 57,64 ----
the context of a diagnostic message. */
struct diagnostic_context
{
! /* 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];
*************** struct diagnostic_context
*** 233,247 ****
/* 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 output_prefixing_rule. Works on 'diagnostic_context *'. */
! #define diagnostic_prefixing_rule(DC) output_prefixing_rule (&(DC)->buffer)
/* 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)
/* True if the last function in which a diagnostic was reported is
different from the current one. */
--- 109,125 ----
/* Extension hook for client. */
#define diagnostic_auxiliary_data(DC) (DC)->x_data
! /* 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) ((DC)->printer->prefixing_rule)
/* Maximum characters per line in automatic line wrapping mode.
Zero means don't wrap lines. */
! #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. */
*************** extern diagnostic_context *global_dc;
*** 294,300 ****
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 *,
--- 172,177 ----
*************** extern void diagnostic_set_info (diagnos
*** 302,328 ****
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 *);
--- 179,184 ----
Index: dwarfout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarfout.c,v
retrieving revision 1.130
diff -p -r1.130 dwarfout.c
*** dwarfout.c 19 Jul 2003 14:47:02 -0000 1.130
--- dwarfout.c 25 Jul 2003 09:44:43 -0000
*************** output_reg_number (rtx rtl)
*** 2036,2044 ****
if (regno >= DWARF_FRAME_REGISTERS)
{
! warning_with_decl (dwarf_last_decl,
! "internal regno botch: `%s' has regno = %d\n",
! regno);
regno = 0;
}
dw2_assemble_integer (4, GEN_INT (DBX_REGISTER_NUMBER (regno)));
--- 2036,2044 ----
if (regno >= DWARF_FRAME_REGISTERS)
{
! 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)));
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.573
diff -p -r1.573 expr.c
*** expr.c 19 Jul 2003 14:47:02 -0000 1.573
--- expr.c 25 Jul 2003 09:44:47 -0000
*************** expand_expr (tree exp, rtx target, enum
*** 6734,6740 ****
case PARM_DECL:
if (!DECL_RTL_SET_P (exp))
{
! error_with_decl (exp, "prior parameter's size depends on `%s'");
return CONST0_RTX (mode);
}
--- 6734,6741 ----
case PARM_DECL:
if (!DECL_RTL_SET_P (exp))
{
! error ("%Hprior parameter's size depends on '%D'",
! &DECL_SOURCE_LOCATION (exp), exp);
return CONST0_RTX (mode);
}
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.448
diff -p -r1.448 function.c
*** function.c 19 Jul 2003 14:47:05 -0000 1.448
--- function.c 25 Jul 2003 09:44:52 -0000
*************** assign_temp (tree type_or_decl, int keep
*** 877,883 ****
if (decl && size == -1
&& TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST)
{
! error_with_decl (decl, "size of variable `%s' is too large");
size = 1;
}
--- 877,884 ----
if (decl && size == -1
&& TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST)
{
! error ("%Hsize of variable '%D' is too large",
! &DECL_SOURCE_LOCATION (decl), decl);
size = 1;
}
*************** uninitialized_vars_warning (tree block)
*** 5567,5581 ****
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");
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'");
}
for (sub = BLOCK_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub))
uninitialized_vars_warning (sub);
--- 5568,5582 ----
not worry that it may be a dangling pointer. */
&& DECL_INITIAL (decl) == NULL_TREE
&& regno_uninitialized (REGNO (DECL_RTL (decl))))
! 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 ("%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);
*************** setjmp_args_warning (void)
*** 5593,5600 ****
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'");
}
/* If this function call setjmp, put all vars into the stack
--- 5594,5601 ----
if (DECL_RTL (decl) != 0
&& GET_CODE (DECL_RTL (decl)) == REG
&& regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
! 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
*************** expand_function_end (void)
*** 6919,6925 ****
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'");
}
/* Delete handlers for nonlocal gotos if nothing uses them. */
--- 6920,6927 ----
decl; decl = TREE_CHAIN (decl))
if (! TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
&& DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl))
! warning ("%Hunused parameter '%D'",
! &DECL_SOURCE_LOCATION (decl), decl);
}
/* Delete handlers for nonlocal gotos if nothing uses them. */
Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.31
diff -p -r1.31 opts.c
*** opts.c 19 Jul 2003 08:13:56 -0000 1.31
--- opts.c 25 Jul 2003 09:44:52 -0000
*************** common_handle_option (size_t scode, cons
*** 1071,1077 ****
break;
case OPT_fmessage_length_:
! output_set_maximum_length (&global_dc->buffer, value);
break;
case OPT_fmove_all_movables:
--- 1071,1077 ----
break;
case OPT_fmessage_length_:
! pp_set_line_maximum_length (global_dc->printer, value);
break;
case OPT_fmove_all_movables:
Index: pretty-print.c
===================================================================
RCS file: pretty-print.c
diff -N pretty-print.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- pretty-print.c 25 Jul 2003 09:44:53 -0000
***************
*** 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')
+ v {
+ 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 = ≈
+ 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 = ≈
+ 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));
+ }
+
+
Index: pretty-print.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/pretty-print.h,v
retrieving revision 1.5
diff -p -r1.5 pretty-print.h
*** pretty-print.h 12 Aug 2002 18:34:51 -0000 1.5
--- pretty-print.h 25 Jul 2003 09:44:53 -0000
***************
*** 1,5 ****
/* Various declarations for language-independent pretty-print subroutines.
! Copyright (C) 2002 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
This file is part of GCC.
--- 1,5 ----
/* Various declarations for language-independent pretty-print subroutines.
! Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
This file is part of GCC.
*************** Software Foundation, 59 Temple Place - S
*** 22,28 ****
#ifndef GCC_PRETTY_PRINT_H
#define GCC_PRETTY_PRINT_H
! #include "diagnostic.h"
/* The type of pretty-printer flags passed to clients. */
typedef unsigned int pp_flags;
--- 22,68 ----
#ifndef GCC_PRETTY_PRINT_H
#define GCC_PRETTY_PRINT_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;
*************** typedef enum
*** 32,100 ****
pp_none, pp_before, pp_after
} pp_padding;
struct pretty_print_info
{
/* Where we print external representation of ENTITY. */
output_buffer *buffer;
pp_flags flags;
/* Where to put whitespace around the entity being formatted. */
pp_padding padding;
};
! #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); \
} while (0)
! #define pp_separate_with(PPI, C) \
! do { \
! pp_character (PPI, C); \
! pp_whitespace (PPI); \
} 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_identifier(PPI, ID) output_add_string (pp_buffer (PPI), ID)
! #define pp_tree_identifier(PPI, T) pp_identifier(PPI, IDENTIFIER_POINTER (T))
!
! #define pp_unsupported_tree(PPI, T) \
! output_verbatim (pp_buffer(PPI), "#`%s' not supported by %s#",\
tree_code_name[(int) TREE_CODE (T)], __FUNCTION__)
#endif /* GCC_PRETTY_PRINT_H */
--- 72,234 ----
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_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(PP, C) \
! do { \
! pp_character (pp_base (PP), C);\
! pp_space (PP); \
} while (0)
! #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(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(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 */
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.322
diff -p -r1.322 stmt.c
*** stmt.c 19 Jul 2003 14:47:13 -0000 1.322
--- stmt.c 25 Jul 2003 09:44:56 -0000
*************** fixup_gotos (struct nesting *thisblock,
*** 986,993 ****
&& 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");
/* Prevent multiple errors for one label. */
DECL_ERROR_ISSUED (f->target) = 1;
}
--- 986,993 ----
&& INSN_UID (first_insn) > INSN_UID (f->before_jump)
&& ! DECL_ERROR_ISSUED (f->target))
{
! 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;
}
*************** warn_about_unused_variables (tree vars)
*** 3636,3642 ****
&& ! TREE_USED (decl)
&& ! DECL_IN_SYSTEM_HEADER (decl)
&& DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl))
! warning_with_decl (decl, "unused variable `%s'");
}
/* Generate RTL code to terminate a binding contour.
--- 3636,3642 ----
&& ! TREE_USED (decl)
&& ! DECL_IN_SYSTEM_HEADER (decl)
&& DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl))
! warning ("%Hunused variable '%D'", &DECL_SOURCE_LOCATION (decl), decl);
}
/* Generate RTL code to terminate a binding contour.
*************** expand_end_bindings (tree vars, int mark
*** 3696,3703 ****
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");
}
}
--- 3696,3703 ----
that must be an error, because gotos without fixups
come from outside all saved stack-levels. */
if (TREE_ADDRESSABLE (chain->label))
! error ("%Hlabel '%D' used before containing binding contour",
! &DECL_SOURCE_LOCATION (chain->label), chain->label);
}
}
Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stor-layout.c,v
retrieving revision 1.163
diff -p -r1.163 stor-layout.c
*** stor-layout.c 24 Jul 2003 20:48:06 -0000 1.163
--- stor-layout.c 25 Jul 2003 09:44:57 -0000
*************** layout_decl (tree decl, unsigned int kno
*** 515,524 ****
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);
else
! warning_with_decl (decl, "size of `%s' is larger than %d bytes",
! larger_than_size);
}
}
--- 515,525 ----
int size_as_int = TREE_INT_CST_LOW (size);
if (compare_tree_int (size, size_as_int) == 0)
! warning ("%Hsize of '%D' is %d bytes",
! &DECL_SOURCE_LOCATION (decl), decl, size_as_int);
else
! warning ("size of '%D' is larger than %d bytes",
! &DECL_SOURCE_LOCATION (decl), decl, larger_than_size);
}
}
*************** place_field (record_layout_info rli, tre
*** 883,891 ****
if (TYPE_ALIGN (type) > desired_align)
{
if (STRICT_ALIGNMENT)
! warning_with_decl (field, "packed attribute causes inefficient alignment for `%s'");
else
! warning_with_decl (field, "packed attribute is unnecessary for `%s'");
}
}
else
--- 884,894 ----
if (TYPE_ALIGN (type) > desired_align)
{
if (STRICT_ALIGNMENT)
! warning ("%Hpacked attribute causes inefficient alignment "
! "for '%D'", &DECL_SOURCE_LOCATION (field), field);
else
! warning ("%Hpacked attribute is unnecessary for '%D'",
! &DECL_SOURCE_LOCATION (field), field);
}
}
else
*************** place_field (record_layout_info rli, tre
*** 900,906 ****
Bump the cumulative size to multiple of field alignment. */
if (warn_padded)
! warning_with_decl (field, "padding struct to align `%s'");
/* If the alignment is still within offset_align, just align
the bit position. */
--- 903,910 ----
Bump the cumulative size to multiple of field alignment. */
if (warn_padded)
! warning ("%Hpadding struct to align '%D'",
! &DECL_SOURCE_LOCATION (field), field);
/* If the alignment is still within offset_align, just align
the bit position. */
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.813
diff -p -r1.813 toplev.c
*** toplev.c 19 Jul 2003 14:47:14 -0000 1.813
--- toplev.c 25 Jul 2003 09:44:59 -0000
*************** check_global_declarations (tree *vec, in
*** 1659,1669 ****
&& ! TREE_PUBLIC (decl))
{
if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
! pedwarn_with_decl (decl,
! "`%s' used but never defined");
else
! warning_with_decl (decl,
! "`%s' declared `static' but never defined");
/* This symbol is effectively an "extern" declaration now. */
TREE_PUBLIC (decl) = 1;
assemble_external (decl);
--- 1659,1669 ----
&& ! TREE_PUBLIC (decl))
{
if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
! pedwarn ("%H'%F' used but never defined",
! &DECL_SOURCE_LOCATION (decl), decl);
else
! 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);
*************** check_global_declarations (tree *vec, in
*** 1684,1690 ****
&& ! (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");
/* Avoid confusing the debug information machinery when there are
errors. */
--- 1684,1691 ----
&& ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
/* Otherwise, ask the language. */
&& (*lang_hooks.decls.warn_unused_global) (decl))
! warning ("%H'%D' defined but not used",
! &DECL_SOURCE_LOCATION (decl), decl);
/* Avoid confusing the debug information machinery when there are
errors. */
*************** rest_of_handle_inlining (tree decl)
*** 2512,2519 ****
timevar_pop (TV_INTEGRATION);
if (lose || ! optimize)
{
! if (warn_inline && DECL_INLINE (decl))
! warning_with_decl (decl, lose);
DECL_ABSTRACT_ORIGIN (decl) = 0;
/* Don't really compile an extern inline function.
If we can't make it inline, pretend
--- 2513,2527 ----
timevar_pop (TV_INTEGRATION);
if (lose || ! optimize)
{
! 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
*************** init_asm_output (const char *name)
*** 4091,4096 ****
--- 4099,4127 ----
}
}
+ /* 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]. */
*************** general_init (const char *argv0)
*** 4110,4115 ****
--- 4141,4153 ----
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);
*************** general_init (const char *argv0)
*** 4132,4141 ****
/* 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. */
--- 4170,4175 ----
Index: toplev.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.h,v
retrieving revision 1.109
diff -p -r1.109 toplev.h
*** toplev.h 19 Jul 2003 13:10:17 -0000 1.109
--- toplev.h 25 Jul 2003 09:44:59 -0000
*************** extern void _fatal_insn (const char *, r
*** 56,75 ****
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 fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
ATTRIBUTE_NORETURN;
! extern void pedwarn (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
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);
--- 56,71 ----
extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
ATTRIBUTE_NORETURN;
extern void warning (const char *, ...);
! extern void error (const char *, ...);
extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
ATTRIBUTE_NORETURN;
! 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);
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 announce_function (tree);
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.69
diff -p -r1.69 tree-inline.c
*** tree-inline.c 23 Jul 2003 16:45:12 -0000 1.69
--- tree-inline.c 25 Jul 2003 09:45:00 -0000
*************** expand_call_inline (tree *tp, int *walk_
*** 1171,1177 ****
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 ("called from here");
}
return NULL_TREE;
--- 1171,1178 ----
if (warn_inline && DECL_INLINE (fn) && !DID_INLINE_FUNC (fn)
&& !DECL_IN_SYSTEM_HEADER (fn))
{
! warning ("%Hinlining failed in call to '%F'",
! &DECL_SOURCE_LOCATION (fn), fn);
warning ("called from here");
}
return NULL_TREE;
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.375
diff -p -r1.375 varasm.c
*** varasm.c 22 Jul 2003 23:30:08 -0000 1.375
--- varasm.c 25 Jul 2003 09:45:02 -0000
*************** named_section (tree decl, const char *na
*** 432,438 ****
{
flags = get_named_section_flags (name);
if ((flags & SECTION_OVERRIDE) == 0)
! error_with_decl (decl, "%s causes a section type conflict");
}
named_section_flags (name, flags);
--- 432,439 ----
{
flags = get_named_section_flags (name);
if ((flags & SECTION_OVERRIDE) == 0)
! error ("%H%D causes a section type conflict",
! &DECL_SOURCE_LOCATION (decl), decl);
}
named_section_flags (name, flags);
*************** make_decl_rtl (tree decl, const char *as
*** 802,816 ****
{
/* First detect errors in declaring global registers. */
if (reg_number == -1)
! error_with_decl (decl, "register name not specified for `%s'");
else if (reg_number < 0)
! error_with_decl (decl, "invalid register name for `%s'");
else if (TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
! error_with_decl (decl,
! "data type of `%s' isn't suitable for a register");
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");
/* Now handle properly declared static register variables. */
else
{
--- 803,819 ----
{
/* First detect errors in declaring global registers. */
if (reg_number == -1)
! error ("%Hregister name not specified for '%D'",
! &DECL_SOURCE_LOCATION (decl), decl);
else if (reg_number < 0)
! error ("%Hinvalid register name for '%D'",
! &DECL_SOURCE_LOCATION (decl), decl);
else if (TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
! 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 ("%Hregister specified for '%D' isn't suitable for data type",
! &DECL_SOURCE_LOCATION (decl), decl);
/* Now handle properly declared static register variables. */
else
{
*************** make_decl_rtl (tree decl, const char *as
*** 854,861 ****
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'");
/* Specifying a section attribute on a variable forces it into a
non-.bss section, and thus it cannot be common. */
--- 857,864 ----
Also handle vars declared register invalidly. */
if (reg_number >= 0 || reg_number == -3)
! 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. */
*************** assemble_variable (tree decl, int top_le
*** 1391,1397 ****
if (! dont_output_data
&& ! host_integerp (DECL_SIZE_UNIT (decl), 1))
{
! error_with_decl (decl, "size of variable `%s' is too large");
return;
}
--- 1394,1401 ----
if (! dont_output_data
&& ! host_integerp (DECL_SIZE_UNIT (decl), 1))
{
! error ("%Hsize of variable '%D' is too large",
! &DECL_SOURCE_LOCATION (decl), decl);
return;
}
*************** assemble_variable (tree decl, int top_le
*** 1429,1437 ****
#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);
align = MAX_OFILE_ALIGNMENT;
}
--- 1433,1441 ----
#endif
if (align > MAX_OFILE_ALIGNMENT)
{
! 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;
}
*************** assemble_variable (tree decl, int top_le
*** 1497,1504 ****
#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);
#endif
/* If the target cannot output uninitialized but not common global data
--- 1501,1509 ----
#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 ("%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
*************** merge_weak (tree newdecl, tree olddecl)
*** 4169,4183 ****
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");
/* 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");
if (SUPPORTS_WEAK)
{
--- 4174,4190 ----
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 ("%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 ("%Hweak declaration of '%D' after first use results "
! "in unspecified behavior",
! &DECL_SOURCE_LOCATION (newdecl), newdecl);
if (SUPPORTS_WEAK)
{
*************** void
*** 4210,4225 ****
declare_weak (tree decl)
{
if (! TREE_PUBLIC (decl))
! error_with_decl (decl, "weak declaration of `%s' must be public");
else if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl))
! error_with_decl (decl, "weak declaration of `%s' must precede definition");
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");
mark_weak (decl);
}
--- 4217,4235 ----
declare_weak (tree decl)
{
if (! TREE_PUBLIC (decl))
! 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 ("%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 ("%Hweak declaration of '%D' not supported",
! &DECL_SOURCE_LOCATION (decl), decl);
mark_weak (decl);
}
Index: cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Make-lang.in,v
retrieving revision 1.157
diff -p -r1.157 Make-lang.in
*** cp/Make-lang.in 7 Jul 2003 19:11:58 -0000 1.157
--- cp/Make-lang.in 25 Jul 2003 09:45:15 -0000
*************** cp/expr.o: cp/expr.c $(CXX_TREE_H) $(TM_
*** 265,272 ****
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/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 \
--- 265,272 ----
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/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 \
Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.225
diff -p -r1.225 error.c
*** cp/error.c 22 Jul 2003 23:30:15 -0000 1.225
--- cp/error.c 25 Jul 2003 09:45:15 -0000
*************** Boston, MA 02111-1307, USA. */
*** 30,61 ****
#include "flags.h"
#include "diagnostic.h"
#include "langhooks-def.h"
enum pad { none, before, after };
! #define sorry_for_unsupported_tree(T) \
! sorry ("`%s' not supported by %s", tree_code_name[(int) TREE_CODE (T)], \
! __FUNCTION__)
!
! #define print_scope_operator(BUFFER) output_add_string ((BUFFER), "::")
! #define print_left_paren(BUFFER) output_add_character ((BUFFER), '(')
! #define print_right_paren(BUFFER) output_add_character ((BUFFER), ')')
! #define print_left_bracket(BUFFER) output_add_character ((BUFFER), '[')
! #define print_right_bracket(BUFFER) output_add_character ((BUFFER), ']')
! #define print_template_argument_list_start(BUFFER) \
! print_non_consecutive_character ((BUFFER), '<')
! #define print_template_argument_list_end(BUFFER) \
! print_non_consecutive_character ((BUFFER), '>')
! #define print_tree_identifier(BUFFER, TID) \
! output_add_string ((BUFFER), IDENTIFIER_POINTER (TID))
! #define print_identifier(BUFFER, ID) output_add_string ((BUFFER), (ID))
! #define separate_with_comma(BUFFER) output_add_string ((BUFFER), ", ")
/* The global buffer where we dump everything. It is there only for
transitional purpose. It is expected, in the near future, to be
completely removed. */
! static output_buffer scratch_buffer_rec;
! static output_buffer *scratch_buffer = &scratch_buffer_rec;
# define NEXT_CODE(T) (TREE_CODE (TREE_TYPE (T)))
--- 30,50 ----
#include "flags.h"
#include "diagnostic.h"
#include "langhooks-def.h"
+ #include "pretty-print.h"
enum pad { none, before, after };
! #define pp_template_argument_list_start(PP) \
! pp_non_consecutive_character (PP, '<')
! #define pp_template_argument_list_end(PP) \
! pp_non_consecutive_character (PP, '>')
! #define pp_separate_with_comma(PP) pp_string (PP, ", ")
/* The global buffer where we dump everything. It is there only for
transitional purpose. It is expected, in the near future, to be
completely removed. */
! static pretty_printer scratch_pretty_printer;
! #define cxx_pp (&scratch_pretty_printer)
# define NEXT_CODE(T) (TREE_CODE (TREE_TYPE (T)))
*************** static void cp_diagnostic_starter (diagn
*** 109,116 ****
static void cp_diagnostic_finalizer (diagnostic_context *, diagnostic_info *);
static void cp_print_error_function (diagnostic_context *, diagnostic_info *);
! static bool cp_printer (output_buffer *, text_info *);
! static void print_non_consecutive_character (output_buffer *, int);
static tree locate_error (const char *, va_list);
static location_t location_of (tree);
--- 98,105 ----
static void cp_diagnostic_finalizer (diagnostic_context *, diagnostic_info *);
static void cp_print_error_function (diagnostic_context *, diagnostic_info *);
! static bool cp_printer (pretty_printer *, text_info *);
! static void pp_non_consecutive_character (pretty_printer *, int);
static tree locate_error (const char *, va_list);
static location_t location_of (tree);
*************** init_error (void)
*** 121,127 ****
diagnostic_finalizer (global_dc) = cp_diagnostic_finalizer;
diagnostic_format_decoder (global_dc) = cp_printer;
! init_output_buffer (scratch_buffer, /* prefix */NULL, /* line-width */0);
}
/* Dump a scope, if deemed necessary. */
--- 110,116 ----
diagnostic_finalizer (global_dc) = cp_diagnostic_finalizer;
diagnostic_format_decoder (global_dc) = cp_printer;
! pp_construct (cxx_pp, NULL, 0);
}
/* Dump a scope, if deemed necessary. */
*************** dump_scope (tree scope, int flags)
*** 139,156 ****
if (scope != global_namespace)
{
dump_decl (scope, f);
! print_scope_operator (scratch_buffer);
}
}
else if (AGGREGATE_TYPE_P (scope))
{
dump_type (scope, f);
! print_scope_operator (scratch_buffer);
}
else if ((flags & TFF_SCOPE) && TREE_CODE (scope) == FUNCTION_DECL)
{
dump_function_decl (scope, f);
! print_scope_operator (scratch_buffer);
}
}
--- 128,145 ----
if (scope != global_namespace)
{
dump_decl (scope, f);
! pp_colon_colon (cxx_pp);
}
}
else if (AGGREGATE_TYPE_P (scope))
{
dump_type (scope, f);
! pp_colon_colon (cxx_pp);
}
else if ((flags & TFF_SCOPE) && TREE_CODE (scope) == FUNCTION_DECL)
{
dump_function_decl (scope, f);
! pp_colon_colon (cxx_pp);
}
}
*************** dump_qualifiers (tree t, enum pad p)
*** 174,185 ****
if (masks[ix] & quals)
{
if (p == before)
! output_add_space (scratch_buffer);
p = before;
! print_identifier (scratch_buffer, names[ix]);
}
if (do_after)
! output_add_space (scratch_buffer);
}
else
p = none;
--- 163,174 ----
if (masks[ix] & quals)
{
if (p == before)
! pp_space (cxx_pp);
p = before;
! pp_identifier (cxx_pp, names[ix]);
}
if (do_after)
! pp_space (cxx_pp);
}
else
p = none;
*************** dump_template_argument_list (tree args,
*** 210,216 ****
for (i = 0; i< n; ++i)
{
if (need_comma)
! separate_with_comma (scratch_buffer);
dump_template_argument (TREE_VEC_ELT (args, i), flags);
need_comma = 1;
}
--- 199,205 ----
for (i = 0; i< n; ++i)
{
if (need_comma)
! pp_separate_with_comma (cxx_pp);
dump_template_argument (TREE_VEC_ELT (args, i), flags);
need_comma = 1;
}
*************** dump_template_parameter (tree parm, int
*** 228,251 ****
{
if (flags & TFF_DECL_SPECIFIERS)
{
! print_identifier (scratch_buffer, "class");
if (DECL_NAME (p))
{
! output_add_space (scratch_buffer);
! print_tree_identifier (scratch_buffer, DECL_NAME (p));
}
}
else if (DECL_NAME (p))
! print_tree_identifier (scratch_buffer, DECL_NAME (p));
else
! print_identifier (scratch_buffer, "{template default argument error}");
}
else
dump_decl (p, flags | TFF_DECL_SPECIFIERS);
if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && a != NULL_TREE)
{
! output_add_string (scratch_buffer, " = ");
if (TREE_CODE (p) == TYPE_DECL || TREE_CODE (p) == TEMPLATE_DECL)
dump_type (a, flags & ~TFF_CHASE_TYPEDEF);
else
--- 217,240 ----
{
if (flags & TFF_DECL_SPECIFIERS)
{
! pp_identifier (cxx_pp, "class");
if (DECL_NAME (p))
{
! pp_space (cxx_pp);
! pp_tree_identifier (cxx_pp, DECL_NAME (p));
}
}
else if (DECL_NAME (p))
! pp_tree_identifier (cxx_pp, DECL_NAME (p));
else
! pp_identifier (cxx_pp, "<template default argument error>");
}
else
dump_decl (p, flags | TFF_DECL_SPECIFIERS);
if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && a != NULL_TREE)
{
! pp_string (cxx_pp, " = ");
if (TREE_CODE (p) == TYPE_DECL || TREE_CODE (p) == TEMPLATE_DECL)
dump_type (a, flags & ~TFF_CHASE_TYPEDEF);
else
*************** dump_template_bindings (tree parms, tree
*** 282,294 ****
}
if (need_comma)
! separate_with_comma (scratch_buffer);
dump_template_parameter (TREE_VEC_ELT (p, i), TFF_PLAIN_IDENTIFIER);
! output_add_string (scratch_buffer, " = ");
if (arg)
dump_template_argument (arg, TFF_PLAIN_IDENTIFIER);
else
! print_identifier (scratch_buffer, "<missing>");
++arg_idx;
need_comma = 1;
--- 271,283 ----
}
if (need_comma)
! pp_separate_with_comma (cxx_pp);
dump_template_parameter (TREE_VEC_ELT (p, i), TFF_PLAIN_IDENTIFIER);
! pp_string (cxx_pp, " = ");
if (arg)
dump_template_argument (arg, TFF_PLAIN_IDENTIFIER);
else
! pp_identifier (cxx_pp, "<missing>");
++arg_idx;
need_comma = 1;
*************** dump_type (tree t, int flags)
*** 313,319 ****
switch (TREE_CODE (t))
{
case UNKNOWN_TYPE:
! print_identifier (scratch_buffer, "<unknown type>");
break;
case TREE_LIST:
--- 302,308 ----
switch (TREE_CODE (t))
{
case UNKNOWN_TYPE:
! pp_identifier (cxx_pp, "<unknown type>");
break;
case TREE_LIST:
*************** dump_type (tree t, int flags)
*** 322,328 ****
break;
case IDENTIFIER_NODE:
! print_tree_identifier (scratch_buffer, t);
break;
case TREE_VEC:
--- 311,317 ----
break;
case IDENTIFIER_NODE:
! pp_tree_identifier (cxx_pp, t);
break;
case TREE_VEC:
*************** dump_type (tree t, int flags)
*** 350,361 ****
break;
case COMPLEX_TYPE:
! output_add_string (scratch_buffer, "__complex__ ");
dump_type (TREE_TYPE (t), flags);
break;
case VECTOR_TYPE:
! output_add_string (scratch_buffer, "__vector__ ");
{
/* The subtype of a VECTOR_TYPE is something like intQI_type_node,
which has no name and is not very useful for diagnostics. So
--- 339,350 ----
break;
case COMPLEX_TYPE:
! pp_string (cxx_pp, "__complex__ ");
dump_type (TREE_TYPE (t), flags);
break;
case VECTOR_TYPE:
! pp_string (cxx_pp, "__vector__ ");
{
/* The subtype of a VECTOR_TYPE is something like intQI_type_node,
which has no name and is not very useful for diagnostics. So
*************** dump_type (tree t, int flags)
*** 368,376 ****
case INTEGER_TYPE:
if (!TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && TREE_UNSIGNED (t))
! output_add_string (scratch_buffer, "unsigned ");
else if (TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && !TREE_UNSIGNED (t))
! output_add_string (scratch_buffer, "signed ");
/* fall through. */
case REAL_TYPE:
--- 357,365 ----
case INTEGER_TYPE:
if (!TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && TREE_UNSIGNED (t))
! pp_string (cxx_pp, "unsigned ");
else if (TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && !TREE_UNSIGNED (t))
! pp_string (cxx_pp, "signed ");
/* fall through. */
case REAL_TYPE:
*************** dump_type (tree t, int flags)
*** 381,421 ****
dump_qualifiers (t, after);
type = flags & TFF_CHASE_TYPEDEF ? TYPE_MAIN_VARIANT (t) : t;
if (TYPE_NAME (type) && TYPE_IDENTIFIER (type))
! print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (type));
else
/* Types like intQI_type_node and friends have no names.
These don't come up in user error messages, but it's nice
to be able to print them from the debugger. */
! print_identifier (scratch_buffer, "<anonymous>");
}
break;
case TEMPLATE_TEMPLATE_PARM:
/* For parameters inside template signature. */
if (TYPE_IDENTIFIER (t))
! print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (t));
else
! print_identifier
! (scratch_buffer, "<anonymous template template parameter>");
break;
case BOUND_TEMPLATE_TEMPLATE_PARM:
{
tree args = TYPE_TI_ARGS (t);
! print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (t));
! print_template_argument_list_start (scratch_buffer);
dump_template_argument_list (args, flags);
! print_template_argument_list_end (scratch_buffer);
}
break;
case TEMPLATE_TYPE_PARM:
dump_qualifiers (t, after);
if (TYPE_IDENTIFIER (t))
! print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (t));
else
! print_identifier
! (scratch_buffer, "<anonymous template type parameter>");
break;
/* This is not always necessary for pointers and such, but doing this
--- 370,408 ----
dump_qualifiers (t, after);
type = flags & TFF_CHASE_TYPEDEF ? TYPE_MAIN_VARIANT (t) : t;
if (TYPE_NAME (type) && TYPE_IDENTIFIER (type))
! pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (type));
else
/* Types like intQI_type_node and friends have no names.
These don't come up in user error messages, but it's nice
to be able to print them from the debugger. */
! pp_identifier (cxx_pp, "<anonymous>");
}
break;
case TEMPLATE_TEMPLATE_PARM:
/* For parameters inside template signature. */
if (TYPE_IDENTIFIER (t))
! pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
else
! pp_identifier (cxx_pp, "<anonymous template template parameter>");
break;
case BOUND_TEMPLATE_TEMPLATE_PARM:
{
tree args = TYPE_TI_ARGS (t);
! pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
! pp_template_argument_list_start (cxx_pp);
dump_template_argument_list (args, flags);
! pp_template_argument_list_end (cxx_pp);
}
break;
case TEMPLATE_TYPE_PARM:
dump_qualifiers (t, after);
if (TYPE_IDENTIFIER (t))
! pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
else
! pp_identifier (cxx_pp, "<anonymous template type parameter>");
break;
/* This is not always necessary for pointers and such, but doing this
*************** dump_type (tree t, int flags)
*** 434,462 ****
}
case TYPENAME_TYPE:
dump_qualifiers (t, after);
! output_add_string (scratch_buffer, "typename ");
dump_typename (t, flags);
break;
case UNBOUND_CLASS_TEMPLATE:
dump_type (TYPE_CONTEXT (t), flags);
! print_scope_operator (scratch_buffer);
! print_identifier (scratch_buffer, "template ");
dump_type (DECL_NAME (TYPE_NAME (t)), flags);
break;
case TYPEOF_TYPE:
! output_add_string (scratch_buffer, "__typeof (");
dump_expr (TYPE_FIELDS (t), flags & ~TFF_EXPR_IN_PARENS);
! print_right_paren (scratch_buffer);
break;
default:
! sorry_for_unsupported_tree (t);
/* Fall through to error. */
case ERROR_MARK:
! print_identifier (scratch_buffer, "<type error>");
break;
}
}
--- 421,449 ----
}
case TYPENAME_TYPE:
dump_qualifiers (t, after);
! pp_string (cxx_pp, "typename ");
dump_typename (t, flags);
break;
case UNBOUND_CLASS_TEMPLATE:
dump_type (TYPE_CONTEXT (t), flags);
! pp_colon_colon (cxx_pp);
! pp_identifier (cxx_pp, "template ");
dump_type (DECL_NAME (TYPE_NAME (t)), flags);
break;
case TYPEOF_TYPE:
! pp_string (cxx_pp, "__typeof (");
dump_expr (TYPE_FIELDS (t), flags & ~TFF_EXPR_IN_PARENS);
! pp_right_paren (cxx_pp);
break;
default:
! pp_unsupported_tree (cxx_pp, t);
/* Fall through to error. */
case ERROR_MARK:
! pp_identifier (cxx_pp, "<type error>");
break;
}
}
*************** dump_typename (tree t, int flags)
*** 473,479 ****
dump_typename (ctx, flags);
else
dump_type (ctx, flags & ~TFF_CLASS_KEY_OR_ENUM);
! print_scope_operator (scratch_buffer);
dump_decl (TYPENAME_TYPE_FULLNAME (t), flags);
}
--- 460,466 ----
dump_typename (ctx, flags);
else
dump_type (ctx, flags & ~TFF_CLASS_KEY_OR_ENUM);
! pp_colon_colon (cxx_pp);
dump_decl (TYPENAME_TYPE_FULLNAME (t), flags);
}
*************** dump_aggr_type (tree t, int flags)
*** 507,514 ****
if (flags & TFF_CLASS_KEY_OR_ENUM)
{
! print_identifier (scratch_buffer, variety);
! output_add_space (scratch_buffer);
}
if (flags & TFF_CHASE_TYPEDEF)
--- 494,501 ----
if (flags & TFF_CLASS_KEY_OR_ENUM)
{
! pp_identifier (cxx_pp, variety);
! pp_space (cxx_pp);
}
if (flags & TFF_CHASE_TYPEDEF)
*************** dump_aggr_type (tree t, int flags)
*** 542,553 ****
if (name == 0 || ANON_AGGRNAME_P (name))
{
if (flags & TFF_CLASS_KEY_OR_ENUM)
! print_identifier (scratch_buffer, "<anonymous>");
else
! output_printf (scratch_buffer, "<anonymous %s>", variety);
}
else
! print_tree_identifier (scratch_buffer, name);
if (tmplate)
dump_template_parms (TYPE_TEMPLATE_INFO (t),
!CLASSTYPE_USE_TEMPLATE (t),
--- 529,540 ----
if (name == 0 || ANON_AGGRNAME_P (name))
{
if (flags & TFF_CLASS_KEY_OR_ENUM)
! pp_identifier (cxx_pp, "<anonymous>");
else
! pp_printf (cxx_pp, "<anonymous %s>", variety);
}
else
! pp_tree_identifier (cxx_pp, name);
if (tmplate)
dump_template_parms (TYPE_TEMPLATE_INFO (t),
!CLASSTYPE_USE_TEMPLATE (t),
*************** dump_type_prefix (tree t, int flags)
*** 589,599 ****
padding = dump_type_prefix (sub, flags);
if (TREE_CODE (sub) == ARRAY_TYPE)
{
! output_add_space (scratch_buffer);
! print_left_paren (scratch_buffer);
}
! output_add_character
! (scratch_buffer, "&*"[TREE_CODE (t) == POINTER_TYPE]);
padding = dump_qualifiers (t, before);
}
break;
--- 576,585 ----
padding = dump_type_prefix (sub, flags);
if (TREE_CODE (sub) == ARRAY_TYPE)
{
! pp_space (cxx_pp);
! pp_left_paren (cxx_pp);
}
! pp_character (cxx_pp, "&*"[TREE_CODE (t) == POINTER_TYPE]);
padding = dump_qualifiers (t, before);
}
break;
*************** dump_type_prefix (tree t, int flags)
*** 604,614 ****
if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */
{
if (padding != none)
! output_add_space (scratch_buffer);
dump_type (TYPE_OFFSET_BASETYPE (t), flags);
! print_scope_operator (scratch_buffer);
}
! output_add_character (scratch_buffer, '*');
padding = dump_qualifiers (t, none);
break;
--- 590,600 ----
if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */
{
if (padding != none)
! pp_space (cxx_pp);
dump_type (TYPE_OFFSET_BASETYPE (t), flags);
! pp_colon_colon (cxx_pp);
}
! pp_star (cxx_pp);
padding = dump_qualifiers (t, none);
break;
*************** dump_type_prefix (tree t, int flags)
*** 617,635 ****
case FUNCTION_TYPE:
padding = dump_type_prefix (TREE_TYPE (t), flags);
if (padding != none)
! output_add_space (scratch_buffer);
! print_left_paren (scratch_buffer);
padding = none;
break;
case METHOD_TYPE:
padding = dump_type_prefix (TREE_TYPE (t), flags);
if (padding != none)
! output_add_space (scratch_buffer);
! print_left_paren (scratch_buffer);
padding = none;
dump_aggr_type (TYPE_METHOD_BASETYPE (t), flags);
! print_scope_operator (scratch_buffer);
break;
case ARRAY_TYPE:
--- 603,621 ----
case FUNCTION_TYPE:
padding = dump_type_prefix (TREE_TYPE (t), flags);
if (padding != none)
! pp_space (cxx_pp);
! pp_left_paren (cxx_pp);
padding = none;
break;
case METHOD_TYPE:
padding = dump_type_prefix (TREE_TYPE (t), flags);
if (padding != none)
! pp_space (cxx_pp);
! pp_left_paren (cxx_pp);
padding = none;
dump_aggr_type (TYPE_METHOD_BASETYPE (t), flags);
! pp_colon_colon (cxx_pp);
break;
case ARRAY_TYPE:
*************** dump_type_prefix (tree t, int flags)
*** 660,669 ****
break;
default:
! sorry_for_unsupported_tree (t);
/* fall through. */
case ERROR_MARK:
! print_identifier (scratch_buffer, "<typeprefixerror>");
break;
}
return padding;
--- 646,655 ----
break;
default:
! pp_unsupported_tree (cxx_pp, t);
/* fall through. */
case ERROR_MARK:
! pp_identifier (cxx_pp, "<typeprefixerror>");
break;
}
return padding;
*************** dump_type_suffix (tree t, int flags)
*** 684,690 ****
case REFERENCE_TYPE:
case OFFSET_TYPE:
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
! print_right_paren (scratch_buffer);
dump_type_suffix (TREE_TYPE (t), flags);
break;
--- 670,676 ----
case REFERENCE_TYPE:
case OFFSET_TYPE:
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
! pp_right_paren (cxx_pp);
dump_type_suffix (TREE_TYPE (t), flags);
break;
*************** dump_type_suffix (tree t, int flags)
*** 693,699 ****
case METHOD_TYPE:
{
tree arg;
! print_right_paren (scratch_buffer);
arg = TYPE_ARG_TYPES (t);
if (TREE_CODE (t) == METHOD_TYPE)
arg = TREE_CHAIN (arg);
--- 679,685 ----
case METHOD_TYPE:
{
tree arg;
! pp_right_paren (cxx_pp);
arg = TYPE_ARG_TYPES (t);
if (TREE_CODE (t) == METHOD_TYPE)
arg = TREE_CHAIN (arg);
*************** dump_type_suffix (tree t, int flags)
*** 711,723 ****
}
case ARRAY_TYPE:
! print_left_bracket (scratch_buffer);
if (TYPE_DOMAIN (t))
{
if (host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0))
! output_host_wide_integer
! (scratch_buffer,
! tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0) + 1);
else if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == MINUS_EXPR)
dump_expr (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0),
flags & ~TFF_EXPR_IN_PARENS);
--- 697,708 ----
}
case ARRAY_TYPE:
! pp_left_bracket (cxx_pp);
if (TYPE_DOMAIN (t))
{
if (host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0))
! pp_wide_integer
! (cxx_pp, tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0) + 1);
else if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == MINUS_EXPR)
dump_expr (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0),
flags & ~TFF_EXPR_IN_PARENS);
*************** dump_type_suffix (tree t, int flags)
*** 727,733 ****
integer_one_node)),
flags & ~TFF_EXPR_IN_PARENS);
}
! print_right_bracket (scratch_buffer);
dump_type_suffix (TREE_TYPE (t), flags);
break;
--- 712,718 ----
integer_one_node)),
flags & ~TFF_EXPR_IN_PARENS);
}
! pp_right_bracket (cxx_pp);
dump_type_suffix (TREE_TYPE (t), flags);
break;
*************** dump_type_suffix (tree t, int flags)
*** 753,759 ****
break;
default:
! sorry_for_unsupported_tree (t);
case ERROR_MARK:
/* Don't mark it here, we should have already done in
dump_type_prefix. */
--- 738,744 ----
break;
default:
! pp_unsupported_tree (cxx_pp, t);
case ERROR_MARK:
/* Don't mark it here, we should have already done in
dump_type_prefix. */
*************** dump_global_iord (tree t)
*** 773,779 ****
else
abort ();
! output_printf (scratch_buffer, "(static %s for %s)", p, input_filename);
}
static void
--- 758,764 ----
else
abort ();
! pp_printf (cxx_pp, "(static %s for %s)", p, input_filename);
}
static void
*************** dump_simple_decl (tree t, tree type, int
*** 782,795 ****
if (flags & TFF_DECL_SPECIFIERS)
{
if (dump_type_prefix (type, flags) != none)
! output_add_space (scratch_buffer);
}
if (!DECL_INITIAL (t) || TREE_CODE (DECL_INITIAL (t)) != TEMPLATE_PARM_INDEX)
dump_scope (CP_DECL_CONTEXT (t), flags);
if (DECL_NAME (t))
dump_decl (DECL_NAME (t), flags);
else
! print_identifier (scratch_buffer, "<anonymous>");
if (flags & TFF_DECL_SPECIFIERS)
dump_type_suffix (type, flags);
}
--- 767,780 ----
if (flags & TFF_DECL_SPECIFIERS)
{
if (dump_type_prefix (type, flags) != none)
! pp_space (cxx_pp);
}
if (!DECL_INITIAL (t) || TREE_CODE (DECL_INITIAL (t)) != TEMPLATE_PARM_INDEX)
dump_scope (CP_DECL_CONTEXT (t), flags);
if (DECL_NAME (t))
dump_decl (DECL_NAME (t), flags);
else
! pp_identifier (cxx_pp, "<anonymous>");
if (flags & TFF_DECL_SPECIFIERS)
dump_type_suffix (type, flags);
}
*************** dump_decl (tree t, int flags)
*** 812,825 ****
if ((flags & TFF_DECL_SPECIFIERS)
&& TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
/* Say `class T' not just `T'. */
! output_add_string (scratch_buffer, "class ");
dump_type (TREE_TYPE (t), flags);
break;
}
}
if (flags & TFF_DECL_SPECIFIERS)
! output_add_string (scratch_buffer, "typedef ");
dump_simple_decl (t, DECL_ORIGINAL_TYPE (t)
? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t),
flags);
--- 797,810 ----
if ((flags & TFF_DECL_SPECIFIERS)
&& TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
/* Say `class T' not just `T'. */
! pp_string (cxx_pp, "class ");
dump_type (TREE_TYPE (t), flags);
break;
}
}
if (flags & TFF_DECL_SPECIFIERS)
! pp_string (cxx_pp, "typedef ");
dump_simple_decl (t, DECL_ORIGINAL_TYPE (t)
? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t),
flags);
*************** dump_decl (tree t, int flags)
*** 828,834 ****
case VAR_DECL:
if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t)))
{
! output_add_string (scratch_buffer, "vtable for ");
my_friendly_assert (TYPE_P (DECL_CONTEXT (t)), 20010720);
dump_type (DECL_CONTEXT (t), flags);
break;
--- 813,819 ----
case VAR_DECL:
if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t)))
{
! pp_string (cxx_pp, "vtable for ");
my_friendly_assert (TYPE_P (DECL_CONTEXT (t)), 20010720);
dump_type (DECL_CONTEXT (t), flags);
break;
*************** dump_decl (tree t, int flags)
*** 840,868 ****
break;
case RESULT_DECL:
! output_add_string (scratch_buffer, "<return value> ");
dump_simple_decl (t, TREE_TYPE (t), flags);
break;
case NAMESPACE_DECL:
dump_scope (CP_DECL_CONTEXT (t), flags);
if (DECL_NAME (t) == anonymous_namespace_name)
! print_identifier (scratch_buffer, "<unnamed>");
else
! print_tree_identifier (scratch_buffer, DECL_NAME (t));
break;
case SCOPE_REF:
dump_decl (TREE_OPERAND (t, 0), flags & ~TFF_DECL_SPECIFIERS);
! print_scope_operator (scratch_buffer);
dump_decl (TREE_OPERAND (t, 1), flags);
break;
case ARRAY_REF:
dump_decl (TREE_OPERAND (t, 0), flags);
! print_left_bracket (scratch_buffer);
dump_decl (TREE_OPERAND (t, 1), flags);
! print_right_bracket (scratch_buffer);
break;
/* So that we can do dump_decl on an aggr type. */
--- 825,853 ----
break;
case RESULT_DECL:
! pp_string (cxx_pp, "<return value> ");
dump_simple_decl (t, TREE_TYPE (t), flags);
break;
case NAMESPACE_DECL:
dump_scope (CP_DECL_CONTEXT (t), flags);
if (DECL_NAME (t) == anonymous_namespace_name)
! pp_identifier (cxx_pp, "<unnamed>");
else
! pp_tree_identifier (cxx_pp, DECL_NAME (t));
break;
case SCOPE_REF:
dump_decl (TREE_OPERAND (t, 0), flags & ~TFF_DECL_SPECIFIERS);
! pp_colon_colon (cxx_pp);
dump_decl (TREE_OPERAND (t, 1), flags);
break;
case ARRAY_REF:
dump_decl (TREE_OPERAND (t, 0), flags);
! pp_left_bracket (cxx_pp);
dump_decl (TREE_OPERAND (t, 1), flags);
! pp_right_bracket (cxx_pp);
break;
/* So that we can do dump_decl on an aggr type. */
*************** dump_decl (tree t, int flags)
*** 875,881 ****
case BIT_NOT_EXPR:
/* This is a pseudo destructor call which has not been folded into
a PSEUDO_DTOR_EXPR yet. */
! output_add_character (scratch_buffer, '~');
dump_type (TREE_OPERAND (t, 0), flags);
break;
--- 860,866 ----
case BIT_NOT_EXPR:
/* This is a pseudo destructor call which has not been folded into
a PSEUDO_DTOR_EXPR yet. */
! pp_complement (cxx_pp);
dump_type (TREE_OPERAND (t, 0), flags);
break;
*************** dump_decl (tree t, int flags)
*** 888,900 ****
case IDENTIFIER_NODE:
if (IDENTIFIER_TYPENAME_P (t))
{
! output_add_string (scratch_buffer, "operator ");
/* Not exactly IDENTIFIER_TYPE_VALUE. */
dump_type (TREE_TYPE (t), flags);
break;
}
else
! print_tree_identifier (scratch_buffer, t);
break;
case OVERLOAD:
--- 873,885 ----
case IDENTIFIER_NODE:
if (IDENTIFIER_TYPENAME_P (t))
{
! pp_string (cxx_pp, "operator ");
/* Not exactly IDENTIFIER_TYPE_VALUE. */
dump_type (TREE_TYPE (t), flags);
break;
}
else
! pp_tree_identifier (cxx_pp, t);
break;
case OVERLOAD:
*************** dump_decl (tree t, int flags)
*** 904,915 ****
if (DECL_CLASS_SCOPE_P (t))
{
dump_type (DECL_CONTEXT (t), flags);
! output_add_string (scratch_buffer, "::");
}
else if (DECL_CONTEXT (t))
{
dump_decl (DECL_CONTEXT (t), flags);
! output_add_string (scratch_buffer, "::");
}
dump_decl (DECL_NAME (t), flags);
break;
--- 889,900 ----
if (DECL_CLASS_SCOPE_P (t))
{
dump_type (DECL_CONTEXT (t), flags);
! pp_colon_colon (cxx_pp);
}
else if (DECL_CONTEXT (t))
{
dump_decl (DECL_CONTEXT (t), flags);
! pp_colon_colon (cxx_pp);
}
dump_decl (DECL_NAME (t), flags);
break;
*************** dump_decl (tree t, int flags)
*** 924,930 ****
if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
dump_global_iord (t);
else if (! DECL_LANG_SPECIFIC (t))
! print_identifier (scratch_buffer, "<internal>");
else
dump_function_decl (t, flags);
break;
--- 909,915 ----
if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
dump_global_iord (t);
else if (! DECL_LANG_SPECIFIC (t))
! pp_identifier (cxx_pp, "<internal>");
else
dump_function_decl (t, flags);
break;
*************** dump_decl (tree t, int flags)
*** 940,958 ****
if (is_overloaded_fn (name))
name = DECL_NAME (get_first_fn (name));
dump_decl (name, flags);
! print_template_argument_list_start (scratch_buffer);
for (args = TREE_OPERAND (t, 1); args; args = TREE_CHAIN (args))
{
dump_template_argument (TREE_VALUE (args), flags);
if (TREE_CHAIN (args))
! separate_with_comma (scratch_buffer);
}
! print_template_argument_list_end (scratch_buffer);
}
break;
case LABEL_DECL:
! print_tree_identifier (scratch_buffer, DECL_NAME (t));
break;
case CONST_DECL:
--- 925,943 ----
if (is_overloaded_fn (name))
name = DECL_NAME (get_first_fn (name));
dump_decl (name, flags);
! pp_template_argument_list_start (cxx_pp);
for (args = TREE_OPERAND (t, 1); args; args = TREE_CHAIN (args))
{
dump_template_argument (TREE_VALUE (args), flags);
if (TREE_CHAIN (args))
! pp_separate_with_comma (cxx_pp);
}
! pp_template_argument_list_end (cxx_pp);
}
break;
case LABEL_DECL:
! pp_tree_identifier (cxx_pp, DECL_NAME (t));
break;
case CONST_DECL:
*************** dump_decl (tree t, int flags)
*** 965,977 ****
else if (DECL_INITIAL (t))
dump_expr (DECL_INITIAL (t), flags | TFF_EXPR_IN_PARENS);
else
! print_identifier (scratch_buffer, "<enumerator>");
break;
case USING_DECL:
! output_add_string (scratch_buffer, "using ");
dump_type (DECL_INITIAL (t), flags);
! print_scope_operator (scratch_buffer);
dump_decl (DECL_NAME (t), flags);
break;
--- 950,962 ----
else if (DECL_INITIAL (t))
dump_expr (DECL_INITIAL (t), flags | TFF_EXPR_IN_PARENS);
else
! pp_identifier (cxx_pp, "<enumerator>");
break;
case USING_DECL:
! pp_string (cxx_pp, "using ");
dump_type (DECL_INITIAL (t), flags);
! pp_colon_colon (cxx_pp);
dump_decl (DECL_NAME (t), flags);
break;
*************** dump_decl (tree t, int flags)
*** 984,994 ****
break;
default:
! sorry_for_unsupported_tree (t);
/* Fallthrough to error. */
case ERROR_MARK:
! print_identifier (scratch_buffer, "<declaration error>");
break;
}
}
--- 969,979 ----
break;
default:
! pp_unsupported_tree (cxx_pp, t);
/* Fallthrough to error. */
case ERROR_MARK:
! pp_identifier (cxx_pp, "<declaration error>");
break;
}
}
*************** dump_template_decl (tree t, int flags)
*** 1012,1018 ****
tree inner_parms = INNERMOST_TEMPLATE_PARMS (parms);
int len = TREE_VEC_LENGTH (inner_parms);
! output_add_string (scratch_buffer, "template<");
/* If we've shown the template prefix, we'd better show the
parameters' and decl's type too. */
--- 997,1003 ----
tree inner_parms = INNERMOST_TEMPLATE_PARMS (parms);
int len = TREE_VEC_LENGTH (inner_parms);
! pp_string (cxx_pp, "template<");
/* If we've shown the template prefix, we'd better show the
parameters' and decl's type too. */
*************** dump_template_decl (tree t, int flags)
*** 1021,1037 ****
for (i = 0; i < len; i++)
{
if (i)
! separate_with_comma (scratch_buffer);
dump_template_parameter (TREE_VEC_ELT (inner_parms, i), flags);
}
! print_template_argument_list_end (scratch_buffer);
! output_add_space (scratch_buffer);
}
nreverse(orig_parms);
if (DECL_TEMPLATE_TEMPLATE_PARM_P (t))
/* Say `template<arg> class TT' not just `template<arg> TT'. */
! output_add_string (scratch_buffer, "class ");
}
if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL)
--- 1006,1022 ----
for (i = 0; i < len; i++)
{
if (i)
! pp_separate_with_comma (cxx_pp);
dump_template_parameter (TREE_VEC_ELT (inner_parms, i), flags);
}
! pp_template_argument_list_end (cxx_pp);
! pp_space (cxx_pp);
}
nreverse(orig_parms);
if (DECL_TEMPLATE_TEMPLATE_PARM_P (t))
/* Say `template<arg> class TT' not just `template<arg> TT'. */
! pp_string (cxx_pp, "class ");
}
if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL)
*************** dump_function_decl (tree t, int flags)
*** 1101,1109 ****
if (!(flags & TFF_DECL_SPECIFIERS))
/* OK */;
else if (DECL_STATIC_FUNCTION_P (t))
! print_identifier (scratch_buffer, "static ");
else if (DECL_VIRTUAL_P (t))
! print_identifier (scratch_buffer, "virtual ");
/* Print the return type? */
if (show_return)
--- 1086,1094 ----
if (!(flags & TFF_DECL_SPECIFIERS))
/* OK */;
else if (DECL_STATIC_FUNCTION_P (t))
! pp_identifier (cxx_pp, "static ");
else if (DECL_VIRTUAL_P (t))
! pp_identifier (cxx_pp, "virtual ");
/* Print the return type? */
if (show_return)
*************** dump_function_decl (tree t, int flags)
*** 1112,1125 ****
if (show_return)
{
dump_type_prefix (TREE_TYPE (fntype), flags);
! output_add_space (scratch_buffer);
}
/* Print the function name. */
if (cname)
{
dump_type (cname, flags);
! print_scope_operator (scratch_buffer);
}
else
dump_scope (CP_DECL_CONTEXT (t), flags);
--- 1097,1110 ----
if (show_return)
{
dump_type_prefix (TREE_TYPE (fntype), flags);
! pp_space (cxx_pp);
}
/* Print the function name. */
if (cname)
{
dump_type (cname, flags);
! pp_colon_colon (cxx_pp);
}
else
dump_scope (CP_DECL_CONTEXT (t), flags);
*************** dump_function_decl (tree t, int flags)
*** 1144,1152 ****
/* If T is a template instantiation, dump the parameter binding. */
if (template_parms != NULL_TREE && template_args != NULL_TREE)
{
! output_add_string (scratch_buffer, " [with ");
dump_template_bindings (template_parms, template_args);
! print_right_bracket (scratch_buffer);
}
}
--- 1129,1137 ----
/* If T is a template instantiation, dump the parameter binding. */
if (template_parms != NULL_TREE && template_args != NULL_TREE)
{
! pp_string (cxx_pp, " [with ");
dump_template_bindings (template_parms, template_args);
! pp_right_bracket (cxx_pp);
}
}
*************** dump_parameters (tree parmtypes, int fla
*** 1159,1187 ****
{
int first;
! print_left_paren (scratch_buffer);
for (first = 1; parmtypes != void_list_node;
parmtypes = TREE_CHAIN (parmtypes))
{
if (!first)
! separate_with_comma (scratch_buffer);
first = 0;
if (!parmtypes)
{
! print_identifier (scratch_buffer, "...");
break;
}
dump_type (TREE_VALUE (parmtypes), flags);
if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && TREE_PURPOSE (parmtypes))
{
! output_add_string (scratch_buffer, " = ");
dump_expr (TREE_PURPOSE (parmtypes), flags | TFF_EXPR_IN_PARENS);
}
}
! print_right_paren (scratch_buffer);
}
/* Print an exception specification. T is the exception specification. */
--- 1144,1172 ----
{
int first;
! pp_left_paren (cxx_pp);
for (first = 1; parmtypes != void_list_node;
parmtypes = TREE_CHAIN (parmtypes))
{
if (!first)
! pp_separate_with_comma (cxx_pp);
first = 0;
if (!parmtypes)
{
! pp_identifier (cxx_pp, "...");
break;
}
dump_type (TREE_VALUE (parmtypes), flags);
if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && TREE_PURPOSE (parmtypes))
{
! pp_string (cxx_pp, " = ");
dump_expr (TREE_PURPOSE (parmtypes), flags | TFF_EXPR_IN_PARENS);
}
}
! pp_right_paren (cxx_pp);
}
/* Print an exception specification. T is the exception specification. */
*************** dump_exception_spec (tree t, int flags)
*** 1191,1197 ****
{
if (t)
{
! output_add_string (scratch_buffer, " throw (");
if (TREE_VALUE (t) != NULL_TREE)
while (1)
{
--- 1176,1182 ----
{
if (t)
{
! pp_string (cxx_pp, " throw (");
if (TREE_VALUE (t) != NULL_TREE)
while (1)
{
*************** dump_exception_spec (tree t, int flags)
*** 1199,1207 ****
t = TREE_CHAIN (t);
if (!t)
break;
! separate_with_comma (scratch_buffer);
}
! print_right_paren (scratch_buffer);
}
}
--- 1184,1192 ----
t = TREE_CHAIN (t);
if (!t)
break;
! pp_separate_with_comma (cxx_pp);
}
! pp_right_paren (cxx_pp);
}
}
*************** dump_function_name (tree t, int flags)
*** 1223,1229 ****
if (DECL_DESTRUCTOR_P (t))
{
! output_add_character (scratch_buffer, '~');
dump_decl (name, TFF_PLAIN_IDENTIFIER);
}
else if (DECL_CONV_FN_P (t))
--- 1208,1214 ----
if (DECL_DESTRUCTOR_P (t))
{
! pp_complement (cxx_pp);
dump_decl (name, TFF_PLAIN_IDENTIFIER);
}
else if (DECL_CONV_FN_P (t))
*************** dump_function_name (tree t, int flags)
*** 1234,1244 ****
declarations, both will have the same name, yet
the types will be different, hence the TREE_TYPE field
of the first name will be clobbered by the second. */
! output_add_string (scratch_buffer, "operator ");
dump_type (TREE_TYPE (TREE_TYPE (t)), flags);
}
else if (IDENTIFIER_OPNAME_P (name))
! print_tree_identifier (scratch_buffer, name);
else
dump_decl (name, flags);
--- 1219,1229 ----
declarations, both will have the same name, yet
the types will be different, hence the TREE_TYPE field
of the first name will be clobbered by the second. */
! pp_string (cxx_pp, "operator ");
dump_type (TREE_TYPE (TREE_TYPE (t)), flags);
}
else if (IDENTIFIER_OPNAME_P (name))
! pp_tree_identifier (cxx_pp, name);
else
dump_decl (name, flags);
*************** dump_template_parms (tree info, int prim
*** 1265,1271 ****
if (primary && flags & TFF_TEMPLATE_NAME)
return;
flags &= ~(TFF_CLASS_KEY_OR_ENUM | TFF_TEMPLATE_NAME);
! print_template_argument_list_start (scratch_buffer);
/* Be careful only to print things when we have them, so as not
to crash producing error messages. */
--- 1250,1256 ----
if (primary && flags & TFF_TEMPLATE_NAME)
return;
flags &= ~(TFF_CLASS_KEY_OR_ENUM | TFF_TEMPLATE_NAME);
! pp_template_argument_list_start (cxx_pp);
/* Be careful only to print things when we have them, so as not
to crash producing error messages. */
*************** dump_template_parms (tree info, int prim
*** 1299,1308 ****
args = TREE_CHAIN (args);
}
if (need_comma)
! separate_with_comma (scratch_buffer);
if (!arg)
! print_identifier (scratch_buffer, "<template parameter error>");
else
dump_template_argument (arg, flags);
need_comma = 1;
--- 1284,1293 ----
args = TREE_CHAIN (args);
}
if (need_comma)
! pp_separate_with_comma (cxx_pp);
if (!arg)
! pp_identifier (cxx_pp, "<template parameter error>");
else
dump_template_argument (arg, flags);
need_comma = 1;
*************** dump_template_parms (tree info, int prim
*** 1322,1333 ****
tree parm = TREE_VALUE (TREE_VEC_ELT (parms, ix));
if (ix)
! separate_with_comma (scratch_buffer);
dump_decl (parm, flags & ~TFF_DECL_SPECIFIERS);
}
}
! print_template_argument_list_end (scratch_buffer);
}
static void
--- 1307,1318 ----
tree parm = TREE_VALUE (TREE_VEC_ELT (parms, ix));
if (ix)
! pp_separate_with_comma (cxx_pp);
dump_decl (parm, flags & ~TFF_DECL_SPECIFIERS);
}
}
! pp_template_argument_list_end (cxx_pp);
}
static void
*************** dump_char (int c)
*** 1336,1375 ****
switch (c)
{
case TARGET_NEWLINE:
! output_add_string (scratch_buffer, "\\n");
break;
case TARGET_TAB:
! output_add_string (scratch_buffer, "\\t");
break;
case TARGET_VT:
! output_add_string (scratch_buffer, "\\v");
break;
case TARGET_BS:
! output_add_string (scratch_buffer, "\\b");
break;
case TARGET_CR:
! output_add_string (scratch_buffer, "\\r");
break;
case TARGET_FF:
! output_add_string (scratch_buffer, "\\f");
break;
case TARGET_BELL:
! output_add_string (scratch_buffer, "\\a");
break;
case '\\':
! output_add_string (scratch_buffer, "\\\\");
break;
case '\'':
! output_add_string (scratch_buffer, "\\'");
break;
case '\"':
! output_add_string (scratch_buffer, "\\\"");
break;
default:
if (ISPRINT (c))
! output_add_character (scratch_buffer, c);
else
! output_formatted_scalar (scratch_buffer, "\\%03o", (unsigned) c);
break;
}
}
--- 1321,1360 ----
switch (c)
{
case TARGET_NEWLINE:
! pp_string (cxx_pp, "\\n");
break;
case TARGET_TAB:
! pp_string (cxx_pp, "\\t");
break;
case TARGET_VT:
! pp_string (cxx_pp, "\\v");
break;
case TARGET_BS:
! pp_string (cxx_pp, "\\b");
break;
case TARGET_CR:
! pp_string (cxx_pp, "\\r");
break;
case TARGET_FF:
! pp_string (cxx_pp, "\\f");
break;
case TARGET_BELL:
! pp_string (cxx_pp, "\\a");
break;
case '\\':
! pp_string (cxx_pp, "\\\\");
break;
case '\'':
! pp_string (cxx_pp, "\\'");
break;
case '\"':
! pp_string (cxx_pp, "\\\"");
break;
default:
if (ISPRINT (c))
! pp_character (cxx_pp, c);
else
! pp_scalar (cxx_pp, "\\%03o", (unsigned) c);
break;
}
}
*************** dump_expr_list (tree l, int flags)
*** 1384,1390 ****
dump_expr (TREE_VALUE (l), flags | TFF_EXPR_IN_PARENS);
l = TREE_CHAIN (l);
if (l)
! separate_with_comma (scratch_buffer);
}
}
--- 1369,1375 ----
dump_expr (TREE_VALUE (l), flags | TFF_EXPR_IN_PARENS);
l = TREE_CHAIN (l);
if (l)
! pp_separate_with_comma (cxx_pp);
}
}
*************** dump_expr (tree t, int flags)
*** 1426,1457 ****
break;
if (values)
! print_tree_identifier (scratch_buffer, TREE_PURPOSE (values));
else
{
/* Value must have been cast. */
! print_left_paren (scratch_buffer);
dump_type (type, flags);
! print_right_paren (scratch_buffer);
goto do_int;
}
}
else if (type == boolean_type_node)
{
if (t == boolean_false_node || integer_zerop (t))
! print_identifier (scratch_buffer, "false");
else if (t == boolean_true_node)
! print_identifier (scratch_buffer, "true");
}
else if (type == char_type_node)
{
! output_add_character (scratch_buffer, '\'');
if (host_integerp (t, TREE_UNSIGNED (type)))
dump_char (tree_low_cst (t, TREE_UNSIGNED (type)));
else
! output_printf (scratch_buffer, "\\x%x",
! (unsigned int) TREE_INT_CST_LOW (t));
! output_add_character (scratch_buffer, '\'');
}
else
{
--- 1411,1442 ----
break;
if (values)
! pp_tree_identifier (cxx_pp, TREE_PURPOSE (values));
else
{
/* Value must have been cast. */
! pp_left_paren (cxx_pp);
dump_type (type, flags);
! pp_right_paren (cxx_pp);
goto do_int;
}
}
else if (type == boolean_type_node)
{
if (t == boolean_false_node || integer_zerop (t))
! pp_identifier (cxx_pp, "false");
else if (t == boolean_true_node)
! pp_identifier (cxx_pp, "true");
}
else if (type == char_type_node)
{
! pp_quote (cxx_pp);
if (host_integerp (t, TREE_UNSIGNED (type)))
dump_char (tree_low_cst (t, TREE_UNSIGNED (type)));
else
! pp_printf (cxx_pp, "\\x%x",
! (unsigned int) TREE_INT_CST_LOW (t));
! pp_quote (cxx_pp);
}
else
{
*************** dump_expr (tree t, int flags)
*** 1462,1496 ****
if (tree_int_cst_sgn (val) < 0)
{
! output_add_character (scratch_buffer, '-');
val = build_int_2 (-TREE_INT_CST_LOW (val),
~TREE_INT_CST_HIGH (val)
+ !TREE_INT_CST_LOW (val));
}
! sprintf (scratch_buffer->digit_buffer,
HOST_WIDE_INT_PRINT_DOUBLE_HEX,
TREE_INT_CST_HIGH (val), TREE_INT_CST_LOW (val));
! output_add_string
! (scratch_buffer, scratch_buffer->digit_buffer);
}
else
! output_host_wide_integer (scratch_buffer, TREE_INT_CST_LOW (t));
}
}
break;
case REAL_CST:
! real_to_decimal (scratch_buffer->digit_buffer, &TREE_REAL_CST (t),
! sizeof (scratch_buffer->digit_buffer), 0, 1);
! output_add_string (scratch_buffer, scratch_buffer->digit_buffer);
break;
case PTRMEM_CST:
! output_add_character (scratch_buffer, '&');
dump_type (PTRMEM_CST_CLASS (t), flags);
! print_scope_operator (scratch_buffer);
! print_tree_identifier
! (scratch_buffer, DECL_NAME (PTRMEM_CST_MEMBER (t)));
break;
case STRING_CST:
--- 1447,1479 ----
if (tree_int_cst_sgn (val) < 0)
{
! pp_minus (cxx_pp);
val = build_int_2 (-TREE_INT_CST_LOW (val),
~TREE_INT_CST_HIGH (val)
+ !TREE_INT_CST_LOW (val));
}
! sprintf (cxx_pp->buffer->digit_buffer,
HOST_WIDE_INT_PRINT_DOUBLE_HEX,
TREE_INT_CST_HIGH (val), TREE_INT_CST_LOW (val));
! pp_string (cxx_pp, cxx_pp->buffer->digit_buffer);
}
else
! pp_wide_integer (cxx_pp, TREE_INT_CST_LOW (t));
}
}
break;
case REAL_CST:
! real_to_decimal (cxx_pp->buffer->digit_buffer, &TREE_REAL_CST (t),
! sizeof (cxx_pp->buffer->digit_buffer), 0, 1);
! pp_string (cxx_pp, cxx_pp->buffer->digit_buffer);
break;
case PTRMEM_CST:
! pp_ampersand (cxx_pp);
dump_type (PTRMEM_CST_CLASS (t), flags);
! pp_colon_colon (cxx_pp);
! pp_tree_identifier (cxx_pp, DECL_NAME (PTRMEM_CST_MEMBER (t)));
break;
case STRING_CST:
*************** dump_expr (tree t, int flags)
*** 1499,1513 ****
int len = TREE_STRING_LENGTH (t) - 1;
int i;
! output_add_character (scratch_buffer, '\"');
for (i = 0; i < len; i++)
dump_char (p[i]);
! output_add_character (scratch_buffer, '\"');
}
break;
case COMPOUND_EXPR:
! print_left_paren (scratch_buffer);
/* Within templates, a COMPOUND_EXPR has only one operand,
containing a TREE_LIST of the two operands. */
if (TREE_CODE (TREE_OPERAND (t, 0)) == TREE_LIST)
--- 1482,1496 ----
int len = TREE_STRING_LENGTH (t) - 1;
int i;
! pp_doublequote (cxx_pp);
for (i = 0; i < len; i++)
dump_char (p[i]);
! pp_doublequote (cxx_pp);
}
break;
case COMPOUND_EXPR:
! pp_left_paren (cxx_pp);
/* Within templates, a COMPOUND_EXPR has only one operand,
containing a TREE_LIST of the two operands. */
if (TREE_CODE (TREE_OPERAND (t, 0)) == TREE_LIST)
*************** dump_expr (tree t, int flags)
*** 1519,1550 ****
else
{
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! separate_with_comma (scratch_buffer);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
}
! print_right_paren (scratch_buffer);
break;
case COND_EXPR:
! print_left_paren (scratch_buffer);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! output_add_string (scratch_buffer, " ? ");
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
! output_add_string (scratch_buffer, " : ");
dump_expr (TREE_OPERAND (t, 2), flags | TFF_EXPR_IN_PARENS);
! print_right_paren (scratch_buffer);
break;
case SAVE_EXPR:
if (TREE_HAS_CONSTRUCTOR (t))
{
! output_add_string (scratch_buffer, "new ");
dump_type (TREE_TYPE (TREE_TYPE (t)), flags);
}
else
! {
! dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! }
break;
case AGGR_INIT_EXPR:
--- 1502,1531 ----
else
{
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! pp_separate_with_comma (cxx_pp);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
}
! pp_right_paren (cxx_pp);
break;
case COND_EXPR:
! pp_left_paren (cxx_pp);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! pp_string (cxx_pp, " ? ");
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
! pp_string (cxx_pp, " : ");
dump_expr (TREE_OPERAND (t, 2), flags | TFF_EXPR_IN_PARENS);
! pp_right_paren (cxx_pp);
break;
case SAVE_EXPR:
if (TREE_HAS_CONSTRUCTOR (t))
{
! pp_string (cxx_pp, "new ");
dump_type (TREE_TYPE (TREE_TYPE (t)), flags);
}
else
! dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
break;
case AGGR_INIT_EXPR:
*************** dump_expr (tree t, int flags)
*** 1557,1574 ****
if (fn && TREE_CODE (fn) == FUNCTION_DECL)
{
if (DECL_CONSTRUCTOR_P (fn))
! print_tree_identifier
! (scratch_buffer, TYPE_IDENTIFIER (TREE_TYPE (t)));
else
dump_decl (fn, 0);
}
else
dump_expr (TREE_OPERAND (t, 0), 0);
}
! print_left_paren (scratch_buffer);
if (TREE_OPERAND (t, 1))
dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags);
! print_right_paren (scratch_buffer);
break;
case CALL_EXPR:
--- 1538,1554 ----
if (fn && TREE_CODE (fn) == FUNCTION_DECL)
{
if (DECL_CONSTRUCTOR_P (fn))
! pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (TREE_TYPE (t)));
else
dump_decl (fn, 0);
}
else
dump_expr (TREE_OPERAND (t, 0), 0);
}
! pp_left_paren (cxx_pp);
if (TREE_OPERAND (t, 1))
dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags);
! pp_right_paren (cxx_pp);
break;
case CALL_EXPR:
*************** dump_expr (tree t, int flags)
*** 1585,1604 ****
if (TREE_CODE (ob) == ADDR_EXPR)
{
dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS);
! output_add_character (scratch_buffer, '.');
}
else if (TREE_CODE (ob) != PARM_DECL
|| strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))
{
dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
! output_add_string (scratch_buffer, "->");
}
args = TREE_CHAIN (args);
}
dump_expr (fn, flags | TFF_EXPR_IN_PARENS);
! print_left_paren (scratch_buffer);
dump_expr_list (args, flags);
! print_right_paren (scratch_buffer);
}
break;
--- 1565,1584 ----
if (TREE_CODE (ob) == ADDR_EXPR)
{
dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS);
! pp_dot (cxx_pp);
}
else if (TREE_CODE (ob) != PARM_DECL
|| strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))
{
dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
! pp_arrow (cxx_pp);
}
args = TREE_CHAIN (args);
}
dump_expr (fn, flags | TFF_EXPR_IN_PARENS);
! pp_left_paren (cxx_pp);
dump_expr_list (args, flags);
! pp_right_paren (cxx_pp);
}
break;
*************** dump_expr (tree t, int flags)
*** 1607,1619 ****
tree type = TREE_OPERAND (t, 1);
tree init = TREE_OPERAND (t, 2);
if (NEW_EXPR_USE_GLOBAL (t))
! print_scope_operator (scratch_buffer);
! output_add_string (scratch_buffer, "new ");
if (TREE_OPERAND (t, 0))
{
! print_left_paren (scratch_buffer);
dump_expr_list (TREE_OPERAND (t, 0), flags);
! output_add_string (scratch_buffer, ") ");
}
if (TREE_CODE (type) == ARRAY_REF)
type = build_cplus_array_type
--- 1587,1599 ----
tree type = TREE_OPERAND (t, 1);
tree init = TREE_OPERAND (t, 2);
if (NEW_EXPR_USE_GLOBAL (t))
! pp_colon_colon (cxx_pp);
! pp_string (cxx_pp, "new ");
if (TREE_OPERAND (t, 0))
{
! pp_left_paren (cxx_pp);
dump_expr_list (TREE_OPERAND (t, 0), flags);
! pp_string (cxx_pp, ") ");
}
if (TREE_CODE (type) == ARRAY_REF)
type = build_cplus_array_type
*************** dump_expr (tree t, int flags)
*** 1624,1630 ****
dump_type (type, flags);
if (init)
{
! print_left_paren (scratch_buffer);
if (TREE_CODE (init) == TREE_LIST)
dump_expr_list (init, flags);
else if (init == void_zero_node)
--- 1604,1610 ----
dump_type (type, flags);
if (init)
{
! pp_left_paren (cxx_pp);
if (TREE_CODE (init) == TREE_LIST)
dump_expr_list (init, flags);
else if (init == void_zero_node)
*************** dump_expr (tree t, int flags)
*** 1633,1639 ****
;
else
dump_expr (init, flags);
! print_right_paren (scratch_buffer);
}
}
break;
--- 1613,1619 ----
;
else
dump_expr (init, flags);
! pp_right_paren (cxx_pp);
}
}
break;
*************** dump_expr (tree t, int flags)
*** 1697,1709 ****
|| strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))
{
dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
! output_add_string (scratch_buffer, "->");
}
}
else
{
dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
! output_add_character (scratch_buffer, '.');
}
dump_expr (TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS);
}
--- 1677,1689 ----
|| strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))
{
dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
! pp_arrow (cxx_pp);
}
}
else
{
dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
! pp_dot (cxx_pp);
}
dump_expr (TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS);
}
*************** dump_expr (tree t, int flags)
*** 1711,1727 ****
case ARRAY_REF:
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! print_left_bracket (scratch_buffer);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
! print_right_bracket (scratch_buffer);
break;
case CONVERT_EXPR:
if (TREE_TYPE (t) && VOID_TYPE_P (TREE_TYPE (t)))
{
! print_left_paren (scratch_buffer);
dump_type (TREE_TYPE (t), flags);
! print_right_paren (scratch_buffer);
dump_expr (TREE_OPERAND (t, 0), flags);
}
else
--- 1691,1707 ----
case ARRAY_REF:
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! pp_left_bracket (cxx_pp);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
! pp_right_bracket (cxx_pp);
break;
case CONVERT_EXPR:
if (TREE_TYPE (t) && VOID_TYPE_P (TREE_TYPE (t)))
{
! pp_left_paren (cxx_pp);
dump_type (TREE_TYPE (t), flags);
! pp_right_paren (cxx_pp);
dump_expr (TREE_OPERAND (t, 0), flags);
}
else
*************** dump_expr (tree t, int flags)
*** 1747,1755 ****
t = TREE_OPERAND (t, 0);
my_friendly_assert (TREE_CODE (t) == CALL_EXPR, 237);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! print_left_paren (scratch_buffer);
dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags);
! print_right_paren (scratch_buffer);
}
else
{
--- 1727,1735 ----
t = TREE_OPERAND (t, 0);
my_friendly_assert (TREE_CODE (t) == CALL_EXPR, 237);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! pp_left_paren (cxx_pp);
dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags);
! pp_right_paren (cxx_pp);
}
else
{
*************** dump_expr (tree t, int flags)
*** 1772,1782 ****
case POSTDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
! print_left_paren (scratch_buffer);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! print_identifier
! (scratch_buffer, operator_name_info[(int)TREE_CODE (t)].name);
! print_right_paren (scratch_buffer);
break;
case NON_LVALUE_EXPR:
--- 1752,1761 ----
case POSTDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
! pp_left_paren (cxx_pp);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! pp_identifier (cxx_pp, operator_name_info[(int)TREE_CODE (t)].name);
! pp_right_paren (cxx_pp);
break;
case NON_LVALUE_EXPR:
*************** dump_expr (tree t, int flags)
*** 1793,1803 ****
if (TREE_CODE (next) == FUNCTION_TYPE)
{
if (flags & TFF_EXPR_IN_PARENS)
! print_left_paren (scratch_buffer);
! output_add_character (scratch_buffer, '*');
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
if (flags & TFF_EXPR_IN_PARENS)
! print_right_paren (scratch_buffer);
break;
}
/* else FALLTHRU */
--- 1772,1782 ----
if (TREE_CODE (next) == FUNCTION_TYPE)
{
if (flags & TFF_EXPR_IN_PARENS)
! pp_left_paren (cxx_pp);
! pp_star (cxx_pp);
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
if (flags & TFF_EXPR_IN_PARENS)
! pp_right_paren (cxx_pp);
break;
}
/* else FALLTHRU */
*************** dump_expr (tree t, int flags)
*** 1821,1829 ****
if (integer_zerop (idx))
{
/* A NULL pointer-to-member constant. */
! output_add_string (scratch_buffer, "((");
dump_type (TREE_TYPE (t), flags);
! output_add_string (scratch_buffer, ") 0)");
break;
}
else if (host_integerp (idx, 0))
--- 1800,1810 ----
if (integer_zerop (idx))
{
/* A NULL pointer-to-member constant. */
! pp_left_paren (cxx_pp);
! pp_left_paren (cxx_pp);
dump_type (TREE_TYPE (t), flags);
! pp_right_paren (cxx_pp);
! pp_string (cxx_pp, ")0)");
break;
}
else if (host_integerp (idx, 0))
*************** dump_expr (tree t, int flags)
*** 1857,1870 ****
if (TREE_TYPE (t) && !CONSTRUCTOR_ELTS (t))
{
dump_type (TREE_TYPE (t), 0);
! output_add_character (scratch_buffer, '(');
! output_add_character (scratch_buffer, ')');
}
else
{
! output_add_character (scratch_buffer, '{');
dump_expr_list (CONSTRUCTOR_ELTS (t), flags);
! output_add_character (scratch_buffer, '}');
}
break;
--- 1838,1851 ----
if (TREE_TYPE (t) && !CONSTRUCTOR_ELTS (t))
{
dump_type (TREE_TYPE (t), 0);
! pp_left_paren (cxx_pp);
! pp_right_paren (cxx_pp);
}
else
{
! pp_left_brace (cxx_pp);
dump_expr_list (CONSTRUCTOR_ELTS (t), flags);
! pp_right_brace (cxx_pp);
}
break;
*************** dump_expr (tree t, int flags)
*** 1889,1900 ****
if (TREE_CODE (ob) == INDIRECT_REF)
{
dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS);
! output_add_string (scratch_buffer, "->*");
}
else
{
dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
! output_add_string (scratch_buffer, ".*");
}
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
}
--- 1870,1881 ----
if (TREE_CODE (ob) == INDIRECT_REF)
{
dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS);
! pp_string (cxx_pp, "->*");
}
else
{
dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
! pp_string (cxx_pp, ".*");
}
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
}
*************** dump_expr (tree t, int flags)
*** 1907,1913 ****
case SCOPE_REF:
dump_type (TREE_OPERAND (t, 0), flags);
! print_scope_operator (scratch_buffer);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
break;
--- 1888,1894 ----
case SCOPE_REF:
dump_type (TREE_OPERAND (t, 0), flags);
! pp_colon_colon (cxx_pp);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
break;
*************** dump_expr (tree t, int flags)
*** 1916,1984 ****
|| TREE_CHAIN (TREE_OPERAND (t, 0)))
{
dump_type (TREE_TYPE (t), flags);
! print_left_paren (scratch_buffer);
dump_expr_list (TREE_OPERAND (t, 0), flags);
! print_right_paren (scratch_buffer);
}
else
{
! print_left_paren (scratch_buffer);
dump_type (TREE_TYPE (t), flags);
! output_add_string (scratch_buffer, ")(");
dump_expr_list (TREE_OPERAND (t, 0), flags);
! print_right_paren (scratch_buffer);
}
break;
case STATIC_CAST_EXPR:
! output_add_string (scratch_buffer, "static_cast<");
goto cast;
case REINTERPRET_CAST_EXPR:
! output_add_string (scratch_buffer, "reinterpret_cast<");
goto cast;
case CONST_CAST_EXPR:
! output_add_string (scratch_buffer, "const_cast<");
goto cast;
case DYNAMIC_CAST_EXPR:
! output_add_string (scratch_buffer, "dynamic_cast<");
cast:
dump_type (TREE_TYPE (t), flags);
! output_add_string (scratch_buffer, ">(");
dump_expr (TREE_OPERAND (t, 0), flags);
! print_right_paren (scratch_buffer);
break;
case ARROW_EXPR:
dump_expr (TREE_OPERAND (t, 0), flags);
! output_add_string (scratch_buffer, "->");
break;
case SIZEOF_EXPR:
case ALIGNOF_EXPR:
if (TREE_CODE (t) == SIZEOF_EXPR)
! output_add_string (scratch_buffer, "sizeof (");
else
{
my_friendly_assert (TREE_CODE (t) == ALIGNOF_EXPR, 0);
! output_add_string (scratch_buffer, "__alignof__ (");
}
if (TYPE_P (TREE_OPERAND (t, 0)))
dump_type (TREE_OPERAND (t, 0), flags);
else
dump_expr (TREE_OPERAND (t, 0), flags);
! print_right_paren (scratch_buffer);
break;
case REALPART_EXPR:
case IMAGPART_EXPR:
! print_identifier (scratch_buffer,
! operator_name_info[TREE_CODE (t)].name);
! output_add_space (scratch_buffer);
dump_expr (TREE_OPERAND (t, 0), flags);
break;
case DEFAULT_ARG:
! print_identifier (scratch_buffer, "<unparsed>");
break;
case TRY_CATCH_EXPR:
--- 1897,1964 ----
|| TREE_CHAIN (TREE_OPERAND (t, 0)))
{
dump_type (TREE_TYPE (t), flags);
! pp_left_paren (cxx_pp);
dump_expr_list (TREE_OPERAND (t, 0), flags);
! pp_right_paren (cxx_pp);
}
else
{
! pp_left_paren (cxx_pp);
dump_type (TREE_TYPE (t), flags);
! pp_string (cxx_pp, ")(");
dump_expr_list (TREE_OPERAND (t, 0), flags);
! pp_right_paren (cxx_pp);
}
break;
case STATIC_CAST_EXPR:
! pp_string (cxx_pp, "static_cast<");
goto cast;
case REINTERPRET_CAST_EXPR:
! pp_string (cxx_pp, "reinterpret_cast<");
goto cast;
case CONST_CAST_EXPR:
! pp_string (cxx_pp, "const_cast<");
goto cast;
case DYNAMIC_CAST_EXPR:
! pp_string (cxx_pp, "dynamic_cast<");
cast:
dump_type (TREE_TYPE (t), flags);
! pp_string (cxx_pp, ">(");
dump_expr (TREE_OPERAND (t, 0), flags);
! pp_right_paren (cxx_pp);
break;
case ARROW_EXPR:
dump_expr (TREE_OPERAND (t, 0), flags);
! pp_arrow (cxx_pp);
break;
case SIZEOF_EXPR:
case ALIGNOF_EXPR:
if (TREE_CODE (t) == SIZEOF_EXPR)
! pp_string (cxx_pp, "sizeof (");
else
{
my_friendly_assert (TREE_CODE (t) == ALIGNOF_EXPR, 0);
! pp_string (cxx_pp, "__alignof__ (");
}
if (TYPE_P (TREE_OPERAND (t, 0)))
dump_type (TREE_OPERAND (t, 0), flags);
else
dump_expr (TREE_OPERAND (t, 0), flags);
! pp_right_paren (cxx_pp);
break;
case REALPART_EXPR:
case IMAGPART_EXPR:
! pp_identifier (cxx_pp, operator_name_info[TREE_CODE (t)].name);
! pp_space (cxx_pp);
dump_expr (TREE_OPERAND (t, 0), flags);
break;
case DEFAULT_ARG:
! pp_identifier (cxx_pp, "<unparsed>");
break;
case TRY_CATCH_EXPR:
*************** dump_expr (tree t, int flags)
*** 1989,1997 ****
case PSEUDO_DTOR_EXPR:
dump_expr (TREE_OPERAND (t, 2), flags);
! output_add_character (scratch_buffer, '.');
dump_type (TREE_OPERAND (t, 0), flags);
! output_add_string (scratch_buffer, "::~");
dump_type (TREE_OPERAND (t, 1), flags);
break;
--- 1969,1978 ----
case PSEUDO_DTOR_EXPR:
dump_expr (TREE_OPERAND (t, 2), flags);
! pp_dot (cxx_pp);
dump_type (TREE_OPERAND (t, 0), flags);
! pp_colon_colon (cxx_pp);
! pp_complement (cxx_pp);
dump_type (TREE_OPERAND (t, 1), flags);
break;
*************** dump_expr (tree t, int flags)
*** 2002,2026 ****
case STMT_EXPR:
/* We don't yet have a way of dumping statements in a
human-readable format. */
! output_add_string (scratch_buffer, "({...})");
break;
case BIND_EXPR:
! output_add_character (scratch_buffer, '{');
dump_expr (TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS);
! output_add_character (scratch_buffer, '}');
break;
case LOOP_EXPR:
! output_add_string (scratch_buffer, "while (1) { ");
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
! output_add_character (scratch_buffer, '}');
break;
case EXIT_EXPR:
! output_add_string (scratch_buffer, "if (");
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
! output_add_string (scratch_buffer, ") break; ");
break;
case BASELINK:
--- 1983,2007 ----
case STMT_EXPR:
/* We don't yet have a way of dumping statements in a
human-readable format. */
! pp_string (cxx_pp, "({...})");
break;
case BIND_EXPR:
! pp_left_brace (cxx_pp);
dump_expr (TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS);
! pp_right_brace (cxx_pp);
break;
case LOOP_EXPR:
! pp_string (cxx_pp, "while (1) { ");
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
! pp_right_brace (cxx_pp);
break;
case EXIT_EXPR:
! pp_string (cxx_pp, "if (");
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
! pp_string (cxx_pp, ") break; ");
break;
case BASELINK:
*************** dump_expr (tree t, int flags)
*** 2029,2052 ****
case EMPTY_CLASS_EXPR:
dump_type (TREE_TYPE (t), flags);
! print_left_paren (scratch_buffer);
! print_right_paren (scratch_buffer);
break;
case NON_DEPENDENT_EXPR:
! output_add_string (scratch_buffer, "<expression of type ");
dump_type (TREE_TYPE (t), flags);
! output_add_character (scratch_buffer, '>');
break;
/* This list is incomplete, but should suffice for now.
It is very important that `sorry' does not call
`report_error_function'. That could cause an infinite loop. */
default:
! sorry_for_unsupported_tree (t);
/* fall through to ERROR_MARK... */
case ERROR_MARK:
! print_identifier (scratch_buffer, "<expression error>");
break;
}
}
--- 2010,2033 ----
case EMPTY_CLASS_EXPR:
dump_type (TREE_TYPE (t), flags);
! pp_left_paren (cxx_pp);
! pp_right_paren (cxx_pp);
break;
case NON_DEPENDENT_EXPR:
! pp_string (cxx_pp, "<expression of type ");
dump_type (TREE_TYPE (t), flags);
! pp_greater (cxx_pp);
break;
/* This list is incomplete, but should suffice for now.
It is very important that `sorry' does not call
`report_error_function'. That could cause an infinite loop. */
default:
! pp_unsupported_tree (cxx_pp, t);
/* fall through to ERROR_MARK... */
case ERROR_MARK:
! pp_identifier (cxx_pp, "<expression error>");
break;
}
}
*************** dump_expr (tree t, int flags)
*** 2054,2080 ****
static void
dump_binary_op (const char *opstring, tree t, int flags)
{
! print_left_paren (scratch_buffer);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! output_add_space (scratch_buffer);
if (opstring)
! print_identifier (scratch_buffer, opstring);
else
! print_identifier (scratch_buffer, "<unknown operator>");
! output_add_space (scratch_buffer);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
! print_right_paren (scratch_buffer);
}
static void
dump_unary_op (const char *opstring, tree t, int flags)
{
if (flags & TFF_EXPR_IN_PARENS)
! print_left_paren (scratch_buffer);
! print_identifier (scratch_buffer, opstring);
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
if (flags & TFF_EXPR_IN_PARENS)
! print_right_paren (scratch_buffer);
}
/* Exported interface to stringifying types, exprs and decls under TFF_*
--- 2035,2061 ----
static void
dump_binary_op (const char *opstring, tree t, int flags)
{
! pp_left_paren (cxx_pp);
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
! pp_space (cxx_pp);
if (opstring)
! pp_identifier (cxx_pp, opstring);
else
! pp_identifier (cxx_pp, "<unknown operator>");
! pp_space (cxx_pp);
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
! pp_right_paren (cxx_pp);
}
static void
dump_unary_op (const char *opstring, tree t, int flags)
{
if (flags & TFF_EXPR_IN_PARENS)
! pp_left_paren (cxx_pp);
! pp_identifier (cxx_pp, opstring);
dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
if (flags & TFF_EXPR_IN_PARENS)
! pp_right_paren (cxx_pp);
}
/* Exported interface to stringifying types, exprs and decls under TFF_*
*************** dump_unary_op (const char *opstring, tre
*** 2083,2123 ****
const char *
type_as_string (tree typ, int flags)
{
! reinit_global_formatting_buffer ();
!
dump_type (typ, flags);
!
! return output_finalize_message (scratch_buffer);
}
const char *
expr_as_string (tree decl, int flags)
{
! reinit_global_formatting_buffer ();
!
dump_expr (decl, flags);
!
! return output_finalize_message (scratch_buffer);
}
const char *
decl_as_string (tree decl, int flags)
{
! reinit_global_formatting_buffer ();
!
dump_decl (decl, flags);
!
! return output_finalize_message (scratch_buffer);
}
const char *
context_as_string (tree context, int flags)
{
! reinit_global_formatting_buffer ();
!
dump_scope (context, flags);
!
! return output_finalize_message (scratch_buffer);
}
/* Generate the three forms of printable names for cxx_printable_name. */
--- 2064,2096 ----
const char *
type_as_string (tree typ, int flags)
{
! pp_clear_output_area (cxx_pp);
dump_type (typ, flags);
! return pp_formatted_text (cxx_pp);
}
const char *
expr_as_string (tree decl, int flags)
{
! pp_clear_output_area (cxx_pp);
dump_expr (decl, flags);
! return pp_formatted_text (cxx_pp);
}
const char *
decl_as_string (tree decl, int flags)
{
! pp_clear_output_area (cxx_pp);
dump_decl (decl, flags);
! return pp_formatted_text (cxx_pp);
}
const char *
context_as_string (tree context, int flags)
{
! pp_clear_output_area (cxx_pp);
dump_scope (context, flags);
! return pp_formatted_text (cxx_pp);
}
/* Generate the three forms of printable names for cxx_printable_name. */
*************** lang_decl_name (tree decl, int v)
*** 2128,2139 ****
if (v >= 2)
return decl_as_string (decl, TFF_DECL_SPECIFIERS);
! reinit_global_formatting_buffer ();
!
if (v == 1 && DECL_CLASS_SCOPE_P (decl))
{
dump_type (CP_DECL_CONTEXT (decl), TFF_PLAIN_IDENTIFIER);
! print_scope_operator (scratch_buffer);
}
if (TREE_CODE (decl) == FUNCTION_DECL)
--- 2101,2111 ----
if (v >= 2)
return decl_as_string (decl, TFF_DECL_SPECIFIERS);
! pp_clear_output_area (cxx_pp);
if (v == 1 && DECL_CLASS_SCOPE_P (decl))
{
dump_type (CP_DECL_CONTEXT (decl), TFF_PLAIN_IDENTIFIER);
! pp_colon_colon (cxx_pp);
}
if (TREE_CODE (decl) == FUNCTION_DECL)
*************** lang_decl_name (tree decl, int v)
*** 2141,2147 ****
else
dump_decl (DECL_NAME (decl), TFF_PLAIN_IDENTIFIER);
! return output_finalize_message (scratch_buffer);
}
static location_t
--- 2113,2119 ----
else
dump_decl (DECL_NAME (decl), TFF_PLAIN_IDENTIFIER);
! return pp_formatted_text (cxx_pp);
}
static location_t
*************** decl_to_string (tree decl, int verbose)
*** 2175,2195 ****
flags |= TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE;
flags |= TFF_TEMPLATE_HEADER;
! reinit_global_formatting_buffer ();
!
dump_decl (decl, flags);
!
! return output_finalize_message (scratch_buffer);
}
static const char *
expr_to_string (tree decl)
{
! reinit_global_formatting_buffer ();
!
dump_expr (decl, 0);
!
! return output_finalize_message (scratch_buffer);
}
static const char *
--- 2147,2163 ----
flags |= TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE;
flags |= TFF_TEMPLATE_HEADER;
! pp_clear_output_area (cxx_pp);
dump_decl (decl, flags);
! return pp_formatted_text (cxx_pp);
}
static const char *
expr_to_string (tree decl)
{
! pp_clear_output_area (cxx_pp);
dump_expr (decl, 0);
! return pp_formatted_text (cxx_pp);
}
static const char *
*************** fndecl_to_string (tree fndecl, int verbo
*** 2200,2210 ****
flags = TFF_EXCEPTION_SPECIFICATION | TFF_DECL_SPECIFIERS;
if (verbose)
flags |= TFF_FUNCTION_DEFAULT_ARGUMENTS;
! reinit_global_formatting_buffer ();
!
dump_decl (fndecl, flags);
!
! return output_finalize_message (scratch_buffer);
}
--- 2168,2176 ----
flags = TFF_EXCEPTION_SPECIFICATION | TFF_DECL_SPECIFIERS;
if (verbose)
flags |= TFF_FUNCTION_DEFAULT_ARGUMENTS;
! pp_clear_output_area (cxx_pp);
dump_decl (fndecl, flags);
! return pp_formatted_text (cxx_pp);
}
*************** language_to_string (enum languages c)
*** 2239,2286 ****
static const char *
parm_to_string (int p)
{
! reinit_global_formatting_buffer ();
!
if (p < 0)
! output_add_string (scratch_buffer, "'this'");
else
! output_decimal (scratch_buffer, p + 1);
!
! return output_finalize_message (scratch_buffer);
}
static const char *
op_to_string (enum tree_code p)
{
! tree id;
!
! id = operator_name_info[(int) p].identifier;
return id ? IDENTIFIER_POINTER (id) : "<unknown>";
}
static const char *
type_to_string (tree typ, int verbose)
{
! int flags;
!
! flags = 0;
if (verbose)
flags |= TFF_CLASS_KEY_OR_ENUM;
flags |= TFF_TEMPLATE_HEADER;
! reinit_global_formatting_buffer ();
!
dump_type (typ, flags);
!
! return output_finalize_message (scratch_buffer);
}
static const char *
assop_to_string (enum tree_code p)
{
! tree id;
!
! id = assignment_operator_name_info[(int) p].identifier;
return id ? IDENTIFIER_POINTER (id) : "{unknown}";
}
--- 2205,2242 ----
static const char *
parm_to_string (int p)
{
! pp_clear_output_area (cxx_pp);
if (p < 0)
! pp_string (cxx_pp, "'this'");
else
! pp_decimal_int (cxx_pp, p + 1);
! return pp_formatted_text (cxx_pp);
}
static const char *
op_to_string (enum tree_code p)
{
! tree id = operator_name_info[(int) p].identifier;
return id ? IDENTIFIER_POINTER (id) : "<unknown>";
}
static const char *
type_to_string (tree typ, int verbose)
{
! int flags = 0;
if (verbose)
flags |= TFF_CLASS_KEY_OR_ENUM;
flags |= TFF_TEMPLATE_HEADER;
! pp_clear_output_area (cxx_pp);
dump_type (typ, flags);
! return pp_formatted_text (cxx_pp);
}
static const char *
assop_to_string (enum tree_code p)
{
! tree id = assignment_operator_name_info[(int) p].identifier;
return id ? IDENTIFIER_POINTER (id) : "{unknown}";
}
*************** args_to_string (tree p, int verbose)
*** 2297,2323 ****
if (TYPE_P (TREE_VALUE (p)))
return type_as_string (p, flags);
! reinit_global_formatting_buffer ();
for (; p; p = TREE_CHAIN (p))
{
if (TREE_VALUE (p) == null_node)
! print_identifier (scratch_buffer, "NULL");
else
dump_type (error_type (TREE_VALUE (p)), flags);
if (TREE_CHAIN (p))
! separate_with_comma (scratch_buffer);
}
! return output_finalize_message (scratch_buffer);
}
static const char *
cv_to_string (tree p, int v)
{
! reinit_global_formatting_buffer ();
!
dump_qualifiers (p, v ? before : none);
!
! return output_finalize_message (scratch_buffer);
}
/* Langhook for print_error_function. */
--- 2253,2277 ----
if (TYPE_P (TREE_VALUE (p)))
return type_as_string (p, flags);
! pp_clear_output_area (cxx_pp);
for (; p; p = TREE_CHAIN (p))
{
if (TREE_VALUE (p) == null_node)
! pp_identifier (cxx_pp, "NULL");
else
dump_type (error_type (TREE_VALUE (p)), flags);
if (TREE_CHAIN (p))
! pp_separate_with_comma (cxx_pp);
}
! return pp_formatted_text (cxx_pp);
}
static const char *
cv_to_string (tree p, int v)
{
! pp_clear_output_area (cxx_pp);
dump_qualifiers (p, v ? before : none);
! return pp_formatted_text (cxx_pp);
}
/* Langhook for print_error_function. */
*************** void
*** 2325,2331 ****
cxx_print_error_function (diagnostic_context *context, const char *file)
{
lhd_print_error_function (context, file);
! output_set_prefix (&context->buffer, file);
maybe_print_instantiation_context (context);
}
--- 2279,2285 ----
cxx_print_error_function (diagnostic_context *context, const char *file)
{
lhd_print_error_function (context, file);
! pp_set_prefix (context->printer, file);
maybe_print_instantiation_context (context);
}
*************** cp_diagnostic_starter (diagnostic_contex
*** 2336,2349 ****
diagnostic_report_current_module (context);
cp_print_error_function (context, diagnostic);
maybe_print_instantiation_context (context);
! output_set_prefix (&context->buffer, diagnostic_build_prefix (diagnostic));
}
static void
cp_diagnostic_finalizer (diagnostic_context *context,
diagnostic_info *diagnostic ATTRIBUTE_UNUSED)
{
! output_destroy_prefix (&context->buffer);
}
/* Print current function onto BUFFER, in the process of reporting
--- 2290,2303 ----
diagnostic_report_current_module (context);
cp_print_error_function (context, diagnostic);
maybe_print_instantiation_context (context);
! pp_set_prefix (context->printer, diagnostic_build_prefix (diagnostic));
}
static void
cp_diagnostic_finalizer (diagnostic_context *context,
diagnostic_info *diagnostic ATTRIBUTE_UNUSED)
{
! pp_destroy_prefix (context->printer);
}
/* Print current function onto BUFFER, in the process of reporting
*************** cp_print_error_function (diagnostic_cont
*** 2354,2377 ****
{
if (diagnostic_last_function_changed (context))
{
! const char *old_prefix = output_prefix (&context->buffer);
char *new_prefix = diagnostic->location.file
? file_name_as_prefix (diagnostic->location.file)
: NULL;
! output_set_prefix (&context->buffer, new_prefix);
if (current_function_decl == NULL)
! output_add_string (&context->buffer, "At global scope:");
else
! output_printf (&context->buffer, "In %s `%s':",
! function_category (current_function_decl),
! cxx_printable_name (current_function_decl, 2));
! output_add_newline (&context->buffer);
diagnostic_set_last_function (context);
! output_destroy_prefix (&context->buffer);
! context->buffer.state.prefix = old_prefix;
}
}
--- 2308,2331 ----
{
if (diagnostic_last_function_changed (context))
{
! const char *old_prefix = context->printer->prefix;
char *new_prefix = diagnostic->location.file
? file_name_as_prefix (diagnostic->location.file)
: NULL;
! pp_set_prefix (context->printer, new_prefix);
if (current_function_decl == NULL)
! pp_string (context->printer, "At global scope:");
else
! pp_printf (context->printer, "In %s `%s':",
! function_category (current_function_decl),
! cxx_printable_name (current_function_decl, 2));
! pp_newline (context->printer);
diagnostic_set_last_function (context);
! pp_destroy_prefix (context->printer);
! context->printer->prefix = old_prefix;
}
}
*************** print_instantiation_full_context (diagno
*** 2417,2426 ****
if (current_function_decl == TINST_DECL (p))
/* Avoid redundancy with the the "In function" line. */;
else
! output_verbatim (&context->buffer,
! "%s: In instantiation of `%s':\n", location.file,
! decl_as_string (TINST_DECL (p),
! TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
location.line = TINST_LINE (p);
location.file = TINST_FILE (p);
--- 2371,2380 ----
if (current_function_decl == TINST_DECL (p))
/* Avoid redundancy with the the "In function" line. */;
else
! pp_verbatim (context->printer,
! "%s: In instantiation of `%s':\n", location.file,
! decl_as_string (TINST_DECL (p),
! TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
location.line = TINST_LINE (p);
location.file = TINST_FILE (p);
*************** print_instantiation_partial_context (dia
*** 2438,2453 ****
{
for (; t; t = TREE_CHAIN (t))
{
! output_verbatim
! (&context->buffer, "%s:%d: instantiated from `%s'\n",
! loc.file, loc.line,
! decl_as_string (TINST_DECL (t),
! TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
loc.line = TINST_LINE (t);
loc.file = TINST_FILE (t);
}
! output_verbatim (&context->buffer, "%s:%d: instantiated from here\n",
! loc.file, loc.line);
}
/* Called from cp_thing to print the template context for an error. */
--- 2392,2406 ----
{
for (; t; t = TREE_CHAIN (t))
{
! pp_verbatim (context->printer, "%s:%d: instantiated from `%s'\n",
! loc.file, loc.line,
! decl_as_string (TINST_DECL (t),
! TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
loc.line = TINST_LINE (t);
loc.file = TINST_FILE (t);
}
! pp_verbatim (context->printer, "%s:%d: instantiated from here\n",
! loc.file, loc.line);
}
/* Called from cp_thing to print the template context for an error. */
*************** print_instantiation_context (void)
*** 2484,2490 ****
%T type.
%V cv-qualifier. */
static bool
! cp_printer (output_buffer *buffer, text_info *text)
{
int verbose = 0;
const char *result;
--- 2437,2443 ----
%T type.
%V cv-qualifier. */
static bool
! cp_printer (pretty_printer *pp, text_info *text)
{
int verbose = 0;
const char *result;
*************** cp_printer (output_buffer *buffer, text_
*** 2519,2525 ****
return false;
}
! output_add_string (buffer, result);
return true;
#undef next_tree
#undef next_tcode
--- 2472,2478 ----
return false;
}
! pp_string (pp, result);
return true;
#undef next_tree
#undef next_tcode
*************** cp_printer (output_buffer *buffer, text_
*** 2528,2540 ****
}
static void
! print_non_consecutive_character (output_buffer *buffer, int c)
{
! const char *p = output_last_position (buffer);
if (p != NULL && *p == c)
! output_add_space (buffer);
! output_add_character (buffer, c);
}
/* These are temporary wrapper functions which handle the historic
--- 2481,2493 ----
}
static void
! pp_non_consecutive_character (pretty_printer *pp, int c)
{
! const char *p = pp_last_position_in_text (pp);
if (p != NULL && *p == c)
! pp_space (pp);
! pp_character (pp, c);
}
/* These are temporary wrapper functions which handle the historic