This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Prefix attributes vs. grammar


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]