[cfe-commits] [PATCH][Review request] emit diagnostics for ignored attributes appear before class/struct/union keywords
Michael.Han at autodesk.com
Tue Dec 21 20:56:51 PST 2010
The attached patch adds a diagnostic kind and makes parser to emit warning diagnostic when it found there are attributes appear before class/struct/union keywords. For gcc compatibility, I have checked that gcc does emit warnings for such ignored attributes so this patch would enable clang to emit similar warnings.
From: John McCall [mailto:rjmccall at apple.com]
Sent: Tuesday, December 14, 2010 12:25 AM
To: Michael Han
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] prefixed gnu style attributes are ignored on tag types
On Dec 13, 2010, at 1:32 AM, Michael Han wrote:
It looks like clang parser ignores gnu style attributes prefixed on the tag types. For example (assume attr is an implementation defined attribute):
class __attribute__((attr)) foo ; // works
__attribute__((attr)) class foo; // doesn't work; the attribute is parsed while parsing declaration specifiers but doesn't get merged into the attribute list while parsing the class specifier. So the attribute never makes to Sema.
I am wondering why the parser ignores the prefixed attributes. Is this for gcc compatibility? (from http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html#Type-Attributes, it looks like prefixed attribute is not one of the "legal" syntax of gcc type attributes).
That position would apply to the declared objects, so we should at least diagnose that they're being ignored here.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3702 bytes
More information about the cfe-commits