This is the mail archive of the
mailing list for the GCC project.
RFC: Deprecate (a little bit) of C++ attribute syntax
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc at gcc dot gnu dot org
- Cc: jason at redhat dot com, nathan at codesourcery dot com, gdr at codesourcery dot com
- Date: Tue, 13 Aug 2002 15:57:47 -0700
- Subject: RFC: Deprecate (a little bit) of C++ attribute syntax
- Reply-to: mark at codesourcery dot com
Currently, the C++ front end accepts this syntax:
int x (3) __attribute__((unused));
Grammatically, in an init-declarator, attributes can come after the
initializer, provided that the initializer is of the parenthesized
form above. (You cannot write "int x = 3 __attribute__((unused));".)
In my opinion, it is a mistake to allow the attributes to come after
the initializer. The reason is that "x" is in scope during its own
initializer. Consider, then, something like this:
int x (__alignof__(x)) __attribute__((aligned (32)));
In order to get 32 into "x", the evaluation of "__alignof__(x)" would
have to be delayed until after the attributes at the end are handled.
This is complicated, and will be slow to boot.
This is not so much of a problem in the current compiler because the
current compiler is buggy; the code above does not compile, saying:
test.C:1: error: `x' was not declared in this scope
The new parser does not have this bug, which caused me to think about
the attribute oddity.
There are, of course, a variety of ways to rewrite things so that the
attributes are not after the initializer; you can put them immediately
after "x" for example. As far as I can tell, this syntax was never
Therefore, I'm proposing deprecating this syntax in GCC 3.3 and
removing it in GCC 3.4 (with the new parser). I'm not sure if I can
get the old parser to actually warn about this (it's confused and
thinks the parenthesized initializer is part of the declarator, but
there is then later magic to untangle that!) -- but I will try.
Mark Mitchell email@example.com
CodeSourcery, LLC http://www.codesourcery.com