[cfe-commits] [PATCH] Improve Clang diagnostic on ignored GNU type attributes

Michael Han Michael.Han at autodesk.com
Mon Dec 12 20:00:41 PST 2011


Hi Eli,

I made two changes and regenerate the patch:

1. Remove ProcessDeclAttributeList from Sema::ParsedFreeStandingDeclSpec
as attributes on the free declaration specifier should be ignored.
2. Warn about C++0x attributes not placed after tags.

In addition also modified several test files in which the attributes are
not placed correctly. All tests passed.

~
Michael

On 11-12-12 下午12:52, "Michael Han" <Michael.Han at autodesk.com> wrote:

>Hi Eli,
>
>> Why exclude C++11 attributes here?  They have the same issue.
>I am not familiar with C++11 attribute syntax so for safety I just skip
>warning about them for now.
>
>> We call ProcessDeclAttributeList in Sema::ParsedFreeStandingDeclSpec in
>>some cases.  At first glance, it looks like a bug, but it needs further
>>investigation.
>Seems a bug.. I'll look into it.
>
>Thanks!
>~
>Michael
>
>-----Original Message-----
>From: Eli Friedman [mailto:eli.friedman at gmail.com]
>Sent: Monday, December 12, 2011 11:53 AM
>To: Michael Han
>Cc: cfe-commits at cs.uiuc.edu
>Subject: Re: [cfe-commits] [PATCH] Improve Clang diagnostic on ignored
>GNU type attributes
>
>On Mon, Dec 12, 2011 at 11:44 AM, Eli Friedman <eli.friedman at gmail.com>
>wrote:
>> On Sun, Dec 11, 2011 at 3:25 PM, Michael Han <Michael.Han at autodesk.com>
>>wrote:
>>> Hi,
>>>
>>>
>>>
>>> This patch improves Clang diagnostic to warn about ignored GNU type
>>> attributes in declaration specifiers, such as
>>> ""__attribute__((aligned)) struct foo", where the attribute should
>>> (according to GCC attribute syntax and implementation) be placed
>>> after the tag to apply to the type declaration.
>>>
>>>
>>>
>>> Please review, thanks!
>>
>> +        if (attrs->isCXX0XAttribute()) continue;
>>
>> Why exclude C++11 attributes here?  They have the same issue.
>>
>> +  }
>> +
>>   // FIXME: Warn on useless attributes
>>
>> Might as well get rid of the FIXME, since you're fixing it. :)
>>
>> Otherwise, looks good!
>
>Err, wait... I actually realized an issue: clang actually does process
>the attributes in question sometimes. :)  We call
>ProcessDeclAttributeList in Sema::ParsedFreeStandingDeclSpec in some
>cases.  At first glance, it looks like a bug, but it needs further
>investigation.
>
>-Eli

-------------- next part --------------
A non-text attachment was scrubbed...
Name: attr-ignored-diag.patch
Type: application/octet-stream
Size: 9597 bytes
Desc: attr-ignored-diag.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111213/221de069/attachment.obj>


More information about the cfe-commits mailing list