C++ Bug (was: Implicit declaration warnings for builtins)
Zack Weinberg
zack@wolery.cumb.org
Sat May 27 16:24:00 GMT 2000
On Sat, May 27, 2000 at 10:50:34PM +0200, Gerald Pfeifer wrote:
> On Mon, 22 May 2000, Zack Weinberg wrote:
> > I got tired of not being warned about implicitly declaring strcmp or
> > something like that. This patch changes the logic to detect implicit
> > declarations, so that builtin function decls genuinely don't count.
> > [...]
> > A similar patch may be appropriate for C++, I haven't looked.
>
> Yes, I just checked and this bug is also present in the C++ frontend.
Fortunately, the code in the C++ front end is much better factored.
The actual fix will be just a few lines, but there's a problem.
c-decl.c sets C_DECL_ANTICIPATED on builtin decls; that's the only way
to distinguish them from normal decls. DECL_BUILT_IN cannot be used
in this context, because it is not true for several functions which
have builtin prototypes, and because it is not cleared when a
prototype appears.
cp/decl.c's builtin_function() does not set any special flags. Okay,
so we add one? Well, there isn't a free DECL_LANG_FLAG to use. I
think. It might be safe to use flag #7 (documented as
DECL_DEAD_FOR_LOCAL, VAR_DECLs only) but I don't know the C++ front
end well enough to be certain. I'm going to try this anyway; any
advice would be appreciated.
zw
More information about the Gcc-bugs
mailing list