Fix attribute/asm handling
commitef6ee0ca65166500215b892c4cc0db43e9432649
authorAl Viro <viro@ftp.linux.org.uk>
Sat, 14 Feb 2009 12:25:35 +0000 (14 12:25 +0000)
committerChristopher Li <sparse@chrisli.org>
Fri, 17 Jul 2009 23:06:22 +0000 (17 23:06 +0000)
treedcef9081aba8a0276e2f880ccf5402e9872feb18
parentdc16c4ea09e27f9c15c58b787f7ee3e110e0b8a4
Fix attribute/asm handling

a) asm aliases are accepted by gcc *only* directly after the top-level
declarator within external declaration (and they make no sense whatsoever
elsewhere - field names, function parameter names, casts, etc. simply
do not reach the assembler).  Anyway, gcc parser will reject those
anywhere else.

b) post-declarator attributes are *not* accepted in nested declarators.
In bitfield declarations they must follow the entire thing, _including_
:<width>.  They are not accepted in typenames either.  Basically, gcc
has distinction between the attributes of type and attributes of
declaration; "after the entire declaration" is for the latter and they
get applied to type only as a fallback.  So that's deliberate on part
of gcc...

c) no attributes in direct-declarator in front of [.....] or (.....).
Again, gcc behaviour.

d) in external declarations only attributes are accepted after commas.
IOW, you can't write int x, const *y, z; and get away with that.
Replacing const with __attribute__((...)) will get it accepted by
gcc, so we need to accept that variant.  However, any qualifiers
in that position will get rejected by anything, including gcc.

Note that there's a damn good reason why such syntax is a bad idea and
that reason applies to attributes as well.  Think what happens if later
we remove 'x' from the example above; 'z' will suddenly become const int.
So I think we want eventually to warn about the use of attributes in
that position as well.  For now I've got it in sync with gcc behaviour.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
parse.c