This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Diagnostic library cleanup, #4
- To: gcc-patches at gcc dot gnu dot org
- Subject: Diagnostic library cleanup, #4
- From: Gabriel Dos Reis <gdr at codesourcery dot com>
- Date: 28 Jun 2001 14:32:16 +0200
- Organization: CodeSourcery, LLC
This adds a `diagnostic_context *' parameter to print_error_function
and default_print_error_function.
Bootstrapped and tested on an i686-pc-linux. No regression.
-- Gaby
2001-06-28 Gabriel Dos Reis <gdr@codesourcery.com>
* diagnostic.c (default_print_error_function): Tweak.
(report_error_function): Likewise.
* toplev.h (default_print_error_function): Move to...
* diagnostic.h: ...here. Add a `diagnostic_context *' parameter.
* tree.h (print_error_function): Move to...
* diagnostic.h: ...here. Add a `diagnostic_context *' parameter.
ch/
* lang.c: #include diagnostic.h
(chill_print_error_function): Add a dummy `diagnostic_context *'.
* Makefile.in (lang.o): Depend on diagnostic.h
cp/
* error.c (lang_print_error_function): Add a `diagnostic_context *'
parameter. Tweak.
f/
* Make-lang.in (f/com.o): Depend on diagnostic.h
* com.c: #include diagnostic.h
(lang_print_error_function): Take a 'diagnostic_context *'.
java/
* lang.c: #include diagnostic.h
(lang_print_error): Add a `diagnostic_context *' parameter.
(java_dummy_print): Likewise.
* Make-lang.in (JAVA_LEX_C): Depend on diagnostic.h
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.c,v
retrieving revision 1.62
diff -p -r1.62 diagnostic.c
*** diagnostic.c 2001/06/27 18:03:03 1.62
--- diagnostic.c 2001/06/28 12:22:15
*************** static int last_error_tick;
*** 121,128 ****
/* Called by report_error_function to print out function name.
Default may be overridden by language front-ends. */
! void (*print_error_function) PARAMS ((const char *)) =
! default_print_error_function;
/* Prevent recursion into the error handler. */
static int diagnostic_lock;
--- 121,128 ----
/* Called by report_error_function to print out function name.
Default may be overridden by language front-ends. */
! void (*print_error_function) PARAMS ((diagnostic_context *, const char *))
! = default_print_error_function;
/* Prevent recursion into the error handler. */
static int diagnostic_lock;
*************** announce_function (decl)
*** 1204,1238 ****
an error. */
void
! default_print_error_function (file)
! const char *file;
{
if (error_function_changed ())
{
char *prefix = file ? build_message_string ("%s: ", file) : NULL;
output_state os;
! os = output_buffer_state (diagnostic_buffer);
! output_set_prefix (diagnostic_buffer, prefix);
if (current_function_decl == NULL)
! output_add_string (diagnostic_buffer, _("At top level:"));
else
{
if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
output_printf
! (diagnostic_buffer, "In method `%s':",
(*decl_printable_name) (current_function_decl, 2));
else
output_printf
! (diagnostic_buffer, "In function `%s':",
(*decl_printable_name) (current_function_decl, 2));
}
! output_add_newline (diagnostic_buffer);
record_last_error_function ();
! output_buffer_to_stream (diagnostic_buffer);
! output_buffer_state (diagnostic_buffer) = os;
free ((char*) prefix);
}
}
--- 1204,1239 ----
an error. */
void
! default_print_error_function (context, file)
! diagnostic_context *context;
! const char *file;
{
if (error_function_changed ())
{
char *prefix = file ? build_message_string ("%s: ", file) : NULL;
output_state os;
! os = output_buffer_state (context);
! output_set_prefix ((output_buffer *)context, prefix);
if (current_function_decl == NULL)
! output_add_string ((output_buffer *)context, _("At top level:"));
else
{
if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
output_printf
! ((output_buffer *)context, "In member function `%s':",
(*decl_printable_name) (current_function_decl, 2));
else
output_printf
! ((output_buffer *)context, "In function `%s':",
(*decl_printable_name) (current_function_decl, 2));
}
! output_add_newline ((output_buffer *)context);
record_last_error_function ();
! output_buffer_to_stream ((output_buffer *)context);
! output_buffer_state (context) = os;
free ((char*) prefix);
}
}
*************** void
*** 1245,1252 ****
report_error_function (file)
const char *file ATTRIBUTE_UNUSED;
{
! report_problematic_module (diagnostic_buffer);
! (*print_error_function) (input_filename);
}
void
--- 1246,1253 ----
report_error_function (file)
const char *file ATTRIBUTE_UNUSED;
{
! report_problematic_module ((output_buffer *)global_dc);
! (*print_error_function) (global_dc, input_filename);
}
void
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.h,v
retrieving revision 1.31
diff -p -r1.31 diagnostic.h
*** diagnostic.h 2001/06/27 18:03:03 1.31
--- diagnostic.h 2001/06/28 12:22:15
*************** extern int error_function_changed PARAMS
*** 310,313 ****
--- 310,321 ----
extern void record_last_error_function PARAMS ((void));
extern void report_problematic_module PARAMS ((output_buffer *));
+ /* Called by report_error_function to print out function name.
+ * Default may be overridden by language front-ends. */
+ extern void (*print_error_function) PARAMS ((diagnostic_context *,
+ const char *));
+
+ extern void default_print_error_function PARAMS ((diagnostic_context *,
+ const char *));
+
#endif /* ! GCC_DIAGNOSTIC_H */
Index: toplev.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.h,v
retrieving revision 1.65
diff -p -r1.65 toplev.h
*** toplev.h 2001/06/10 13:47:57 1.65
--- toplev.h 2001/06/28 12:22:15
*************** extern void error_with_file_and_line PAR
*** 84,90 ****
ATTRIBUTE_PRINTF_3;
extern void sorry PARAMS ((const char *, ...))
ATTRIBUTE_PRINTF_1;
- extern void default_print_error_function PARAMS ((const char *));
extern void report_error_function PARAMS ((const char *));
extern void rest_of_decl_compilation PARAMS ((union tree_node *,
--- 84,89 ----
Index: tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.h,v
retrieving revision 1.249
diff -p -r1.249 tree.h
*** tree.h 2001/06/27 06:55:28 1.249
--- tree.h 2001/06/28 12:22:16
*************** extern void init_decl_processing PARAMS
*** 2651,2660 ****
/* Function to identify which front-end produced the output file. */
extern const char *lang_identify PARAMS ((void));
- /* Called by report_error_function to print out function name.
- * Default may be overridden by language front-ends. */
- extern void (*print_error_function) PARAMS ((const char *));
-
/* Function to replace the DECL_LANG_SPECIFIC field of a DECL with a copy. */
extern void copy_lang_decl PARAMS ((tree));
--- 2651,2656 ----
Index: ch/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ch/Makefile.in,v
retrieving revision 1.32
diff -p -r1.32 Makefile.in
*** Makefile.in 2001/06/10 13:47:57 1.32
--- Makefile.in 2001/06/28 12:22:21
*************** grant.o: grant.c $(CONFIG_H) $(CHILL_TRE
*** 286,292 ****
inout.o : inout.c $(CONFIG_H) $(CHILL_TREE_H) $(srcdir)/../flags.h \
$(srcdir)/../input.h $(srcdir)/../system.h $(srcdir)/../toplev.h
lang.o : lang.c $(CONFIG_H) $(CHILL_TREE_H) $(srcdir)/../input.h lex.h \
! $(srcdir)/../system.h $(srcdir)/../toplev.h $(EXPR_H) $(RTL_H)
lex.o : lex.c $(CONFIG_H) $(CHILL_TREE_H) $(RTL_H) $(srcdir)/../flags.h \
$(srcdir)/../input.h $(srcdir)/parse.h $(srcdir)/../system.h \
$(srcdir)/../toplev.h lex.h $(srcdir)/../dwarfout.h hash.h
--- 286,293 ----
inout.o : inout.c $(CONFIG_H) $(CHILL_TREE_H) $(srcdir)/../flags.h \
$(srcdir)/../input.h $(srcdir)/../system.h $(srcdir)/../toplev.h
lang.o : lang.c $(CONFIG_H) $(CHILL_TREE_H) $(srcdir)/../input.h lex.h \
! $(srcdir)/../system.h $(srcdir)/../toplev.h $(EXPR_H) $(RTL_H) \
! $(srcdir)/../diagnostic.h
lex.o : lex.c $(CONFIG_H) $(CHILL_TREE_H) $(RTL_H) $(srcdir)/../flags.h \
$(srcdir)/../input.h $(srcdir)/parse.h $(srcdir)/../system.h \
$(srcdir)/../toplev.h lex.h $(srcdir)/../dwarfout.h hash.h
Index: ch/lang.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ch/lang.c,v
retrieving revision 1.18
diff -p -r1.18 lang.c
*** lang.c 2001/02/04 23:18:43 1.18
--- lang.c 2001/06/28 12:22:21
*************** Boston, MA 02111-1307, USA. */
*** 29,34 ****
--- 29,35 ----
#include "toplev.h"
#include "rtl.h"
#include "expr.h"
+ #include "diagnostic.h"
/* Type node for boolean types. */
*************** const char* chill_real_input_filename;
*** 54,60 ****
extern FILE* finput;
static int deep_const_expr PARAMS ((tree));
! static void chill_print_error_function PARAMS ((const char *));
/* Return 1 if the expression tree given has all
constant nodes as its leaves,otherwise. */
--- 55,62 ----
extern FILE* finput;
static int deep_const_expr PARAMS ((tree));
! static void chill_print_error_function PARAMS ((diagnostic_context *,
! const char *));
/* Return 1 if the expression tree given has all
constant nodes as its leaves,otherwise. */
*************** lang_decode_option (argc, argv)
*** 229,235 ****
}
static void
! chill_print_error_function (file)
const char *file;
{
static tree last_error_function = NULL_TREE;
--- 231,238 ----
}
static void
! chill_print_error_function (context, file)
! diagnostic_context *buffer __attribute__((__unused__));
const char *file;
{
static tree last_error_function = NULL_TREE;
Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/error.c,v
retrieving revision 1.156
diff -p -r1.156 error.c
*** error.c 2001/06/26 19:18:37 1.156
--- error.c 2001/06/28 12:22:23
*************** static void dump_scope PARAMS ((tree, in
*** 116,122 ****
static void dump_template_parms PARAMS ((tree, int, int));
static const char *function_category PARAMS ((tree));
! static void lang_print_error_function PARAMS ((const char *));
static void maybe_print_instantiation_context PARAMS ((output_buffer *));
static void print_instantiation_full_context PARAMS ((output_buffer *));
static void print_instantiation_partial_context PARAMS ((output_buffer *, tree,
--- 116,123 ----
static void dump_template_parms PARAMS ((tree, int, int));
static const char *function_category PARAMS ((tree));
! static void lang_print_error_function PARAMS ((diagnostic_context *,
! const char *));
static void maybe_print_instantiation_context PARAMS ((output_buffer *));
static void print_instantiation_full_context PARAMS ((output_buffer *));
static void print_instantiation_partial_context PARAMS ((output_buffer *, tree,
*************** cv_to_string (p, v)
*** 2470,2485 ****
}
static void
! lang_print_error_function (file)
const char *file;
{
output_state os;
! default_print_error_function (file);
! os = output_buffer_state (diagnostic_buffer);
! output_set_prefix (diagnostic_buffer, file);
! maybe_print_instantiation_context (diagnostic_buffer);
! output_buffer_state (diagnostic_buffer) = os;
}
static void
--- 2471,2487 ----
}
static void
! lang_print_error_function (context, file)
! diagnostic_context *context;
const char *file;
{
output_state os;
! default_print_error_function (context, file);
! os = output_buffer_state (context);
! output_set_prefix ((output_buffer *)context, file);
! maybe_print_instantiation_context ((output_buffer *)context);
! output_buffer_state (context) = os;
}
static void
Index: f/Make-lang.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/f/Make-lang.in,v
retrieving revision 1.84
diff -p -r1.84 Make-lang.in
*** Make-lang.in 2001/06/10 13:23:19 1.84
--- Make-lang.in 2001/06/28 12:22:23
*************** f/com.o: f/com.c f/proj.h $(CONFIG_H) $(
*** 417,423 ****
f/malloc.h f/info.h f/info-b.def f/info-k.def f/info-w.def f/target.h f/bad.h \
f/bad.def f/where.h glimits.h f/top.h f/lex.h f/type.h f/intrin.h \
f/intrin.def f/lab.h f/symbol.h f/symbol.def f/equiv.h f/storag.h f/global.h \
! f/name.h f/expr.h f/implic.h f/src.h f/st.h $(GGC_H) toplev.h
f/data.o: f/data.c f/proj.h $(CONFIG_H) $(SYSTEM_H) f/data.h f/bld.h f/bld-op.def \
f/bit.h f/malloc.h f/com.h f/com-rt.def $(TREE_H) f/info.h f/info-b.def \
f/info-k.def f/info-w.def f/target.h f/bad.h f/bad.def f/where.h glimits.h \
--- 417,423 ----
f/malloc.h f/info.h f/info-b.def f/info-k.def f/info-w.def f/target.h f/bad.h \
f/bad.def f/where.h glimits.h f/top.h f/lex.h f/type.h f/intrin.h \
f/intrin.def f/lab.h f/symbol.h f/symbol.def f/equiv.h f/storag.h f/global.h \
! f/name.h f/expr.h f/implic.h f/src.h f/st.h $(GGC_H) toplev.h diagnostic.h
f/data.o: f/data.c f/proj.h $(CONFIG_H) $(SYSTEM_H) f/data.h f/bld.h f/bld-op.def \
f/bit.h f/malloc.h f/com.h f/com-rt.def $(TREE_H) f/info.h f/info-b.def \
f/info-k.def f/info-w.def f/target.h f/bad.h f/bad.def f/where.h glimits.h \
Index: f/com.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/f/com.c,v
retrieving revision 1.122
diff -p -r1.122 com.c
*** com.c 2001/06/02 15:42:21 1.122
--- com.c 2001/06/28 12:22:25
*************** the Free Software Foundation, 59 Temple
*** 89,94 ****
--- 89,95 ----
#include "output.h" /* Must follow tree.h so TREE_CODE is defined! */
#include "convert.h"
#include "ggc.h"
+ #include "diagnostic.h"
#endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
#define FFECOM_GCC_INCLUDE 1 /* Enable -I. */
*************** lang_printable_name (tree decl, int v)
*** 13989,13995 ****
#if BUILT_FOR_270
static void
! lang_print_error_function (const char *file)
{
static ffeglobal last_g = NULL;
static ffesymbol last_s = NULL;
--- 13990,13996 ----
#if BUILT_FOR_270
static void
! lang_print_error_function (diagnostic_context *context, const char *file)
{
static ffeglobal last_g = NULL;
static ffesymbol last_s = NULL;
Index: java/Make-lang.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/Make-lang.in,v
retrieving revision 1.62
diff -p -r1.62 Make-lang.in
*** Make-lang.in 2001/06/01 16:51:18 1.62
--- Make-lang.in 2001/06/28 12:22:28
*************** java/jcf-write.o: java/jcf-write.c $(CON
*** 266,272 ****
java/jv-scan.o: java/jv-scan.c $(CONFIG_H) $(SYSTEM_H) version.h
java/jvgenmain.o: java/jvgenmain.c $(CONFIG_H) $(JAVA_TREE_H) $(SYSTEM_H)
java/lang.o: java/lang.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h input.h \
! toplev.h $(SYSTEM_H) $(RTL_H) $(EXPR_H)
java/mangle.o: java/mangle.c $(CONFIG_H) java/jcf.h $(JAVA_TREE_H) $(SYSTEM_H) \
toplev.h $(GGC_H)
java/mangle_name.o: java/mangle_name.c $(CONFIG_H) java/jcf.h $(JAVA_TREE_H) \
--- 266,272 ----
java/jv-scan.o: java/jv-scan.c $(CONFIG_H) $(SYSTEM_H) version.h
java/jvgenmain.o: java/jvgenmain.c $(CONFIG_H) $(JAVA_TREE_H) $(SYSTEM_H)
java/lang.o: java/lang.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h input.h \
! toplev.h $(SYSTEM_H) $(RTL_H) $(EXPR_H) diagnostic.h
java/mangle.o: java/mangle.c $(CONFIG_H) java/jcf.h $(JAVA_TREE_H) $(SYSTEM_H) \
toplev.h $(GGC_H)
java/mangle_name.o: java/mangle_name.c $(CONFIG_H) java/jcf.h $(JAVA_TREE_H) \
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/lang.c,v
retrieving revision 1.65
diff -p -r1.65 lang.c
*** lang.c 2001/04/19 20:28:05 1.65
--- lang.c 2001/06/28 12:22:29
*************** The Free Software Foundation is independ
*** 37,42 ****
--- 37,43 ----
#include "flags.h"
#include "xref.h"
#include "ggc.h"
+ #include "diagnostic.h"
struct string_option
{
*************** static void java_init_options PARAMS ((v
*** 50,57 ****
static int java_decode_option PARAMS ((int, char **));
static void put_decl_string PARAMS ((const char *, int));
static void put_decl_node PARAMS ((tree));
! static void java_dummy_print PARAMS ((const char *));
! static void lang_print_error PARAMS ((const char *));
static int process_option_with_no PARAMS ((char *,
struct string_option *,
int));
--- 51,58 ----
static int java_decode_option PARAMS ((int, char **));
static void put_decl_string PARAMS ((const char *, int));
static void put_decl_node PARAMS ((tree));
! static void java_dummy_print PARAMS ((diagnostic_context *, const char *));
! static void lang_print_error PARAMS ((diagnostic_context *, const char *));
static int process_option_with_no PARAMS ((char *,
struct string_option *,
int));
*************** lang_printable_name_wls (decl, v)
*** 592,598 ****
is the value of the hook print_error_function, called from toplev.c. */
static void
! lang_print_error (file)
const char *file;
{
static tree last_error_function_context = NULL_TREE;
--- 593,600 ----
is the value of the hook print_error_function, called from toplev.c. */
static void
! lang_print_error (context, file)
! diagnostic_context *context __attribute__((__unused__));
const char *file;
{
static tree last_error_function_context = NULL_TREE;
*************** java_init ()
*** 673,679 ****
function prototypes. */
static void
! java_dummy_print (s)
const char *s __attribute__ ((__unused__));
{
}
--- 675,682 ----
function prototypes. */
static void
! java_dummy_print (c, s)
! diagnostic_context *c __attribute__ ((__unused__));
const char *s __attribute__ ((__unused__));
{
}