proposed patch: protos for warning(), error()
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Tue Apr 14 13:21:00 GMT 1998
> From: Robert Lipe <robertl@dgii.com>
>
> 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
Great work Robert. I have two concerns about implementation
with respect to using rtl.h and tree.h.
The first question is about files which don't link against
toplev.o but do include one of rtl.h or tree.h. For example, gen*.c
includes rtl.h. These files supply their own static copy of `fatal',
and don't get it from toplev.c. Right now, I don't think the intended
functionality is too different between these `fatal' functions, but
its still not clean to declare a function extern in a header
supposedly to get it from toplev.o and then define a copy statically
in the local module.
I guess we could eliminate the local copy and link gen*.c and
wherever else this comes up against toplev.o. Does this make sense to
do given the intended purpose of toplev.c?
The second issue is about the so called "middle-end" files which
include both tree.h and rtl.h. If rtl.h is included first then, because
of the fact that toplev.h is macro wrapped against multiple inclusion (a
good thing IMHO), you'll never get the prototypes for the stuff wrapped
by TREE_OPERAND. (A quick glance shows this occurs in c-lex.c,
varasm.c, function.c and a few other places.) Its obviously not hard to
correct when we notice it, but it introduces a maintenance headache and
I was wondering if there is an easy way to zap this minor problem in
some clean automated fashion. (Moving the stuff wrapped by TREE_OPERAND
outside the header file wrapper didn't seem clean, but it would work...)
--Kaveh
> /* 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__
>
> [...]
>
> /*
> * 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 */
--
Kaveh R. Ghazi Project Manager / Custom Development
ghazi@caip.rutgers.edu Icon CMT Corp.
More information about the Gcc
mailing list