[cfe-commits] [PATCH] Supporting __declspec(align)

Aaron Ballman aaron at aaronballman.com
Fri Jun 8 05:47:56 PDT 2012

On Wed, Jun 6, 2012 at 9:20 PM, John McCall <rjmccall at apple.com> wrote:
> On Jun 6, 2012, at 5:23 PM, Aaron Ballman wrote:
>> On Mon, Jun 4, 2012 at 4:17 PM, Aaron Ballman <aaron at aaronballman.com> wrote:
>>> This patch is to fix PR12631, and basically just turns on existing
>>> functionality.  __declspec(align)'s behavior (documented on MSDN here:
>>> <http://msdn.microsoft.com/en-us/library/83ythb65(v=vs.100).aspx>)
>>> matches what we already support for __attribute__((aligned)).  I've
>>> also included a test case to ensure the behavior matches expectations.
> __attribute__((aligned)) is a little funny in that it's got multiple spellings
> ("align" and "aligned") and takes 0 or 1 arguments.  I think this patch will
> make us accept "__declspec(align)" and "__declspec(aligned(16))";  I
> assume that the latter is wrong and the former might be wrong.
> In either case, you should be able to filter these easily by checking the
> identifier info on the parsed attribute, as well as whether it has an
> argument.  Please also test these possibilities.

You are correct, but it's a bit moot.  We don't emit any diagnostics
for unknown or malformed declspecs.  I've added some logic to test
whether the identifier is wrong, or if it is missing a parameter.
However, the fact still remains that declspecs aren't properly
diagnosed anyway.  So I didn't add any test cases for those

So I think my next patch will be a refactoring of the way we parse
declspecs so that we handle them a bit better.  With that patch, I'll
go ahead and add diagnostics for aligned and align sans parameter and
make some more comprehensive tests.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: declspec_align.patch
Type: application/octet-stream
Size: 1159 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120608/0be2aa27/attachment.obj>

More information about the cfe-commits mailing list