implicitly_declare and C++
Joe Buck
jbuck@synopsys.com
Tue Sep 16 14:53:00 GMT 1997
For a long time, g++ has supported the old C notion that if an unknown
identifier is seen in a form that looks like a function call, it is
implicitly declared as a function with C linkage that returns "int".
The user's only options are either to receive warnings about this
(the default) or to turn off these warnings. This is, in effect, a
GNU extension that can't be turned off except with -pedantic-errors,
and even that doesn't quite have the desired effect, since you can't
block g++ from saying that this is an extern "C" function returning an
int as far as further parsing is concerned.
This really annoys me, since it is never the response I want when I make a
typographical error. C++ programmers, except in very rare circumstances,
never deliberately intend implicit declaration these days (so this
behavior is never intended), and the usual effect of the implicit
declaration in my code is to generate a large cascade of error messages:
one for each argument to the function that has a copy constructor, plus
messages for invalid use of the return value, which is assumed to be int.
Maybe a new type of token can be returned in this case, and the grammar
could have a match for UNDECLARED_FUNCTION followed by an argument list.
This way we would parse the argument list, but would not attempt to build
a call -- instead the result would be an error node.
More information about the Gcc
mailing list