This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Prefix attributes vs. grammar
- To: Mark Mitchell <mark at codesourcery dot com>
- Subject: Re: Prefix attributes vs. grammar
- From: Stan Shebs <shebs at apple dot com>
- Date: Tue, 24 Jul 2001 16:59:50 -0700
- CC: gcc at gcc dot gnu dot org
- References: <217300000.996016790@warlock.codesourcery.com>
Mark Mitchell wrote:
>
> [...]
> I am thinking that the new C++ parser is going to allow attributes only
> directly after a decl-specifier-seq; in other words, you can do:
>
> int __attribute__((__stdcall__)) f (double __attribute__ ((unused)) x);
>
> but not the other stuff shown above. In other words, prefix attributes
> are just like postfix attributes, only they come before the declarator
> instead of afterwards.
I think that what you're describing does generally correspond to the
mental model that people have when using attributes. Unfortunately,
I also suspect that there are mass quantities of code that assume the
attribute could be placed almost anywhere within a declaration, and
worse, the attribute is buried inside a macro for portability, and
users have scattered the macros randomly, not knowing what they
expand into.
Would it be possible to have the parser accumulate any pre-prefix
attributes and only process them when all decl specifiers have been
seen? That could even be used as the tighter definition of attribute
locations ("may appear anywhere, but effect is as if had been placed
after the last decl specifier before a declarator"). Still ugly, but
no worse than some of the standardized C++ syntax... :-)
Stan