This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: position of section() attribute question
On Thu, 9 Jun 2005, DJ Delorie wrote:
>
> > "section" attributes are presently storage-class-like (similar to
> > "static") and only work on declarations.
>
> Ok, I see that we set the "apply to decl" bit for "section". I guess
> the question is - why? Would it be more consistent to keep track of
> where it is given, and complain if it is applied to the type instead
> of the decl?
>
> Or is it as simple as "because the programmer expects it this way" ? ;-)
The various exceptions of the form "if an attribute is applied to the type
of a decl which can only apply to a decl, then apply it to the decl" are
there because they represent forms used by existing code.
In principle I'd prefer storage class attributes to be in the declaration
specifiers (and nowhere else), and attributes on types to be after "*" or
"(" in nested declarators (and nowhere else), and attributes on
struct/union/enum definitions to be after the struct/union/enum keyword,
and attributes on labels not to be there at all. But though these
positions are syntactically cleaner and less ambiguous, most code and GCC
documentation uses the less clear do-what-I-mean positions instead.
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
joseph@codesourcery.com (CodeSourcery mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)