This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 3.2.1 draft release notes, 3rd draft
On Tue, Oct 15, 2002 at 10:08:46AM -0700, Mark Mitchell wrote:
> >Then how about adding a rule something like the following to the bison
> >grammar (yes, I know these are the wrong terminal names, but the idea
> >should be clear):
> >
> > TYPEDEF ID '=' error ';'
> > { error("Please use __typeof() instead");}
>
> Along these lines, one could perhaps even do the transformation at that
> point.
>
> TYPEDEF ID = expression ;
>
> { /* Do whatever you do for the typeof case. */ }
It's worth pointing out that the grammar does not distinguish between
typedef declarations and other declarations. It's all handled by
datadef: declspecs declarator '=' init ';'
(simplified for clarity) The present error message comes from the
semantics layer, c-decl.c:start_decl():
if (initialized)
/* Is it valid for this decl to have an initializer at all?
If not, set INITIALIZED to zero, which will indirectly
tell `finish_decl' to ignore the initializer once it is parsed. */
switch (TREE_CODE (decl))
{
case TYPE_DECL:
error ("typedef `%s' is initialized",
IDENTIFIER_POINTER (DECL_NAME (decl)));
initialized = 0;
break;
It would be easy to insert in here
advice ("Please use __typeof() instead");
("advice" is a diagnostic category I propose for helpful advice, such
as this, or the "Each undeclared identifier is reported only once"
message, which can be shut up with -fno-advice; right now, imagine
that it reads "error")
"Trying to do the above transformation" boils down to my original
patch that fixed the bug in the extension.
zw