[cfe-commits] [PATCH][Review request] emit diagnostics for ignored attributes appear before class/struct/union keywords

Michael Han Michael.Han at autodesk.com
Tue Dec 21 20:56:51 PST 2010


Hi John,

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. 

Cheers
~Michael

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:


Greetings,
 
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.

John.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: attributes.patch
Type: application/octet-stream
Size: 3702 bytes
Desc: attributes.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101222/26d97ca2/attachment.obj>


More information about the cfe-commits mailing list