Init-declarator-list and GNU GCC attribute grammar

I am updating the C-based built-in parser, among others, providing the correct __ attribute__ support.

Since I cannot find any official BNF-style grammar that describes the GNU GCC __ attribute__ idea (other than http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html ), I extract bits and pieces from C ++ x11 standard and comments on various implementations found on the Internet.

I almost did it (at least when it comes to the parsing examples included in the GCC document above), but one specific example gave me a headache without a hint of a solution in external sources.

An example is as follows:

__attribute__((noreturn)) void d0 (void),
         __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
          d2 (void);

The attached description states that:

The list of attribute qualifiers can be displayed immediately before the declarator (except the first one) in the list of declarators, separated by commas, in the declaration of more than one identifier using a single list of qualifiers and qualifiers. Such attribute specifiers apply only to the one before whose declarator they appear.

Thus, leading me to this solution:

init-declarator-list:
 init-declarator
 init-declarator-list , attribute-specifier-seq[opt] init-declarator

I know this works, but I would like confirmation / support if this is the right way to resolve the above case.

Thank,

Wojciech

EDIT: this link (albeit a bit dated) gives a solution just like mine: http://plg.uwaterloo.ca/~cforall/gcc.y strange, I haven't stumbled upon this before, only now that I have done a search the __ extension__ keyword.

+5
1

GCC 2.X.X , . , .

, GCC...

+1

All Articles