proposed patch: protos for warning(), error()
Robert Lipe
robertl@dgii.com
Mon Apr 13 22:36:00 GMT 1998
On March 6, in response to my babbling about ways to prototype some things
in toplevel.c, Jim Wilson wrote:
> All front-end files include tree.h. All back-end files include rtl.h.
> All middle-end files include one or both of them. Thus you get fairly
> complete coverage by putting stuff in these two files. This is convenient,
> but not the best design. A toplev.h file would be better.
This turned out to be the key revelation to not having to touch every
file in this project to add '#include toplev.h' and not have to even
further uglify the makefile dependencies. The fact that both of these
include gansidecl.h makes things even easier.
It turns out all the plumbing is already present. If you just make
create a toplev.h and force tree.h and rtl.h to include it (and deal
with a slight bit of ugliness in doing so) and patch two lines in
Makefile.in it's entirely possible to get this coverage with a very
small amount of actual work.
I've bootstrapped C with this patch (C++ fails for other reasons already
discussed). Since it uses existing infrastructure, I don't expect this
to be any more of a portability hassle than the existing code. I haven't
picked through the call sites to address any warnings that are exposed
by this patch. It should make Kaveh's numbers less noisy with complaints
about warning() and error() not being protoed.
I expect this will be the source of some discussion, so I haven't really
prepared this in a "ready to be submitted" (i.e. no ChangeLog) form. It's
really meant to be read by humans, not patch.
Comments, please.
RJL
/* toplev.h - Various declarations for functions found in toplev.c
Copyright (C) 1998 Free Software Foundation, Inc.
*/
#ifndef __GCC_TOPLEV_H__
#define __GCC_TOPLEV_H__
extern void print_time PROTO ((char *, int));
extern int get_run_time PROTO ((void));
extern void debug_start_source_file PROTO ((char *));
extern void debug_end_source_file PROTO ((unsigned));
extern void debug_define PROTO ((unsigned, char *));
extern void debug_undef PROTO ((unsigned, char *));
extern void fatal PVPROTO ((char *, ...))
ATTRIBUTE_PRINTF_1;
extern void fatal_io_error PROTO ((char *));
extern void warning PVPROTO ((char *, ...))
ATTRIBUTE_PRINTF_1;
extern void error PVPROTO ((char *, ...))
ATTRIBUTE_PRINTF_1;
extern void pedwarn PVPROTO ((char *, ...))
ATTRIBUTE_PRINTF_1;
extern void pedwarn_with_file_and_line PVPROTO ((char *, int, char *, ...))
ATTRIBUTE_PRINTF_3;
extern void warning_with_file_and_line PVPROTO ((char *, int, char *, ...))
ATTRIBUTE_PRINTF_3;
extern void error_with_file_and_line PVPROTO ((char *, int, char *, ...))
ATTRIBUTE_PRINTF_3;
extern void sorry PVPROTO ((char *s, ...))
ATTRIBUTE_PRINTF_1;
extern void default_print_error_function PROTO ((char *));
extern void report_error_function PROTO ((char *));
/*
* If we weren't included via a tree.h, we don't know what a `tree' is.
* Of course, if we don't know what a tree is, we aren't going to need
* these prototyped anyway.
*
*/
#if defined TREE_OPERAND
extern void rest_of_decl_compilation PROTO ((tree, char *, int, int));
extern void rest_of_type_compilation PROTO ((tree, int));
extern void rest_of_compilation PROTO ((tree));
extern void pedwarn_with_decl PVPROTO ((tree, char *, ...));
extern void warning_with_decl PVPROTO ((tree, char *, ...));
extern void error_with_decl PVPROTO ((tree, char *, ...));
extern void announce_function PROTO ((tree));
#endif /* TREE_OPERAND */
#endif /* __GCC_TOPLEV_H */
Index: Makefile.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/Makefile.in,v
retrieving revision 1.85
diff -u -p -r1.85 Makefile.in
--- Makefile.in 1998/04/10 00:31:10 1.85
+++ Makefile.in 1998/04/14 05:31:34
@@ -670,9 +670,9 @@ DPBIT_FUNCS = _pack_df _unpack_df _addsu
# If it is, rm *.o is an easy way to do it.
# CONFIG_H = $(host_xm_file) $(tm_file)
CONFIG_H =
-RTL_BASE_H = rtl.h rtl.def gansidecl.h machmode.h machmode.def
+RTL_BASE_H = rtl.h rtl.def gansidecl.h toplev.h machmode.h machmode.def
RTL_H = $(RTL_BASE_H) genrtl.h
-TREE_H = tree.h real.h tree.def gansidecl.h machmode.h machmode.def
+TREE_H = tree.h real.h tree.def gansidecl.h toplev.h machmode.h machmode.def
BASIC_BLOCK_H = basic-block.h bitmap.h
DEMANGLE_H = demangle.h gansidecl.h
RECOG_H = recog.h gansidecl.h
Index: genrecog.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/genrecog.c,v
retrieving revision 1.9
diff -u -p -r1.9 genrecog.c
--- genrecog.c 1998/04/03 16:35:26 1.9
+++ genrecog.c 1998/04/14 05:31:48
@@ -188,7 +188,6 @@ static void change_state PROTO((char *,
static char *copystr PROTO((char *));
static void mybzero PROTO((char *, unsigned));
static void mybcopy PROTO((char *, char *, unsigned));
-static void fatal PROTO((char *));
char *xrealloc PROTO((char *, unsigned));
char *xmalloc PROTO((unsigned));
void fancy_abort PROTO((void));
Index: rtl.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/rtl.h,v
retrieving revision 1.25
diff -u -p -r1.25 rtl.h
--- rtl.h 1998/04/11 00:28:07 1.25
+++ rtl.h 1998/04/14 05:31:55
@@ -172,6 +172,7 @@ typedef struct rtx_def
} *rtx;
#include "gansidecl.h"
+#include "toplev.h"
#define NULL_RTX (rtx) 0
@@ -1288,22 +1289,6 @@ extern void expand_dec PROTO ((rtx, rt
extern rtx expand_mult_highpart PROTO ((enum machine_mode, rtx,
unsigned HOST_WIDE_INT, rtx,
int, int));
-
-/* In toplev.c */
-extern void strip_off_ending PROTO ((char *, int));
-extern void print_time PROTO ((char *, int));
-extern int get_run_time PROTO ((void));
-#if 0
-extern void fatal PVPROTO ((char *, ...));
-extern void warning PVPROTO ((char *, ...));
-extern void error PVPROTO ((char *, ...));
-#endif
-extern void pfatal_with_name PROTO ((char *));
-extern void fancy_abort PROTO ((void));
-extern int count_error PROTO ((int));
-extern void pedwarn PVPROTO ((char *, ...));
-extern void warning_for_asm PVPROTO ((rtx, char *, ...));
-extern void error_for_asm PVPROTO ((rtx, char *, ...));
/* In global.c */
#ifdef BUFSIZ
Index: tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/tree.h,v
retrieving revision 1.24
diff -u -p -r1.24 tree.h
--- tree.h 1998/04/13 11:38:16 1.24
+++ tree.h 1998/04/14 05:31:58
@@ -1225,6 +1225,8 @@ union tree_node
#include "gansidecl.h"
+#include "toplev.h"
+
#define NULL_TREE (tree) NULL
/* The following functions accept a wide integer argument. Rather than
@@ -2105,34 +2107,6 @@ extern void fixup_signed_type PROTO ((t
extern void make_decl_rtl PROTO ((tree, char *, int));
extern void make_decl_one_only PROTO ((tree));
extern void variable_section PROTO ((tree, int));
-
-/* toplev.c */
-extern void print_time PROTO ((char *, int));
-extern int get_run_time PROTO ((void));
-extern void debug_start_source_file PROTO ((char *));
-extern void debug_end_source_file PROTO ((unsigned));
-extern void debug_define PROTO ((unsigned, char *));
-extern void debug_undef PROTO ((unsigned, char *));
-extern void rest_of_decl_compilation PROTO ((tree, char *, int, int));
-extern void rest_of_type_compilation PROTO ((tree, int));
-extern void rest_of_compilation PROTO ((tree));
-extern void fatal PVPROTO ((char *, ...));
-extern void fatal_io_error PROTO ((char *));
-#if 0
-extern void warning PVPROTO ((char *, ...));
-extern void error PVPROTO ((char *, ...));
-#endif
-extern void pedwarn PVPROTO ((char *, ...));
-extern void pedwarn_with_decl PVPROTO ((tree, char *, ...));
-extern void pedwarn_with_file_and_line PVPROTO ((char *, int, char *, ...));
-extern void warning_with_file_and_line PVPROTO ((char *, int, char *, ...));
-extern void warning_with_decl PVPROTO ((tree, char *, ...));
-extern void error_with_decl PVPROTO ((tree, char *, ...));
-extern void error_with_file_and_line PVPROTO ((char *, int, char *, ...));
-extern void sorry PVPROTO ((char *s, ...));
-extern void default_print_error_function PROTO ((char *));
-extern void report_error_function PROTO ((char *));
-extern void announce_function PROTO ((tree));
/* In fold-const.c */
extern int div_and_round_double PROTO ((enum tree_code, int,
--
Robert Lipe http://www.dgii.com/people/robertl robertl@dgii.com
(WEB ADDRESS MAY BE TEMPORARILY UNAVAILABLE)
More information about the Gcc
mailing list