Page MenuHomePhabricator

[MSVC Compat] Support for '__unaligned' attribute in function declaration
Needs ReviewPublic

Authored by olga.a.chupina on Feb 29 2016, 3:38 AM.

Details

Reviewers
rnk
Summary

This patch supports using '__unaligned' attribute in function declaration:

struct UnalignedS {

void foo(double) __unaligned { ; }

};

void bar(void (UnalignedS::*pf)(double)__unaligned);

Olga Chupina,
Software Engineer,
Intel Compiler Team

Diff Detail

Event Timeline

olga.a.chupina retitled this revision from to [MSVC Compat] Support for '__unaligned' attribute in function declaration.
olga.a.chupina updated this object.
olga.a.chupina added a reviewer: rnk.
olga.a.chupina updated this object.
olga.a.chupina added a subscriber: cfe-commits.

Reid, cloud you please review the patch.

aaron.ballman added inline comments.
lib/Parse/ParseDecl.cpp
4811

MSDN suggests that __unaligned is only valid on a pointer declaration. Is there something this is expected to support, or does MSVC just happen to silently accept the keyword in this position?

rnk edited edge metadata.Mar 14 2016, 9:24 AM

Unless there is a compelling example of Microsoft or a popular third-party header relying on this behavior, I don't think we should implement it.

lib/Parse/ParseDecl.cpp
4813

This will allow __unaligned in a variety of other locations where we shouldn't accept it.

olga.a.chupina added inline comments.Mar 16 2016, 1:43 AM
lib/Parse/ParseDecl.cpp
4811

It rather silently accepts the keyword in this position.

4813

Could you please help me with narrowing it down to the case I'm interested in?

In D17709#374561, @rnk wrote:

Unless there is a compelling example of Microsoft or a popular third-party header relying on this behavior, I don't think we should implement it.

Agreed.

lib/Parse/ParseDecl.cpp
4811

I'm not keen on inferring undocumented behaviors from MSVC keywords; we should only accept if there's some reason to do so (we don't want to hijack MSVC's keyword and give it different behavior than MSVC).