[PATCH] D17709: [MSVC Compat] Support for '__unaligned' attribute in function declaration

2016-02-29 Thread Olga Chupina via cfe-commits
olga.a.chupina created this revision.
olga.a.chupina added a reviewer: rnk.
olga.a.chupina added a subscriber: cfe-commits.

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

struct UnalignedS {
  void foo(double) __unaligned { ; }
};

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

http://reviews.llvm.org/D17709

Files:
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -4808,7 +4808,9 @@
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
 case tok::kw___unaligned:
-  if (AttrReqs & AR_DeclspecAttributesParsed) {
+  // Allow __unaligned in function definition after a parameter list
+  if ((AttrReqs & AR_DeclspecAttributesParsed) ||
+  (Tok.getKind() == tok::kw___unaligned)) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
   }
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -1782,7 +1782,8 @@
 return TPResult::Error;
 
   // cv-qualifier-seq
-  while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict))
+  while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict,
+ tok::kw___unaligned))
 ConsumeToken();
 
   // ref-qualifier[opt]
Index: test/SemaCXX/MicrosoftExtensions.cpp
===
--- test/SemaCXX/MicrosoftExtensions.cpp
+++ test/SemaCXX/MicrosoftExtensions.cpp
@@ -80,6 +80,10 @@
 // __unaligned handling
 typedef char __unaligned *aligned_type;
 typedef struct UnalignedTag { int f; } __unaligned *aligned_type2;
+struct UnalignedS {
+  void foo(double) __unaligned { ; }
+};
+void bar(void (UnalignedS::*pf)(double)__unaligned);
 
 
 template void h1(T (__stdcall M::* const )()) { }


Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -4808,7 +4808,9 @@
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
 case tok::kw___unaligned:
-  if (AttrReqs & AR_DeclspecAttributesParsed) {
+  // Allow __unaligned in function definition after a parameter list
+  if ((AttrReqs & AR_DeclspecAttributesParsed) ||
+  (Tok.getKind() == tok::kw___unaligned)) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
   }
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -1782,7 +1782,8 @@
 return TPResult::Error;
 
   // cv-qualifier-seq
-  while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict))
+  while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict,
+ tok::kw___unaligned))
 ConsumeToken();
 
   // ref-qualifier[opt]
Index: test/SemaCXX/MicrosoftExtensions.cpp
===
--- test/SemaCXX/MicrosoftExtensions.cpp
+++ test/SemaCXX/MicrosoftExtensions.cpp
@@ -80,6 +80,10 @@
 // __unaligned handling
 typedef char __unaligned *aligned_type;
 typedef struct UnalignedTag { int f; } __unaligned *aligned_type2;
+struct UnalignedS {
+  void foo(double) __unaligned { ; }
+};
+void bar(void (UnalignedS::*pf)(double)__unaligned);
 
 
 template void h1(T (__stdcall M::* const )()) { }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17709: [MSVC Compat] Support for '__unaligned' attribute in function declaration

2016-03-14 Thread Olga Chupina via cfe-commits
olga.a.chupina added a comment.

Reid, cloud you please review the patch.


http://reviews.llvm.org/D17709



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17709: [MSVC Compat] Support for '__unaligned' attribute in function declaration

2016-03-16 Thread Olga Chupina via cfe-commits
olga.a.chupina added inline comments.


Comment at: lib/Parse/ParseDecl.cpp:4811
@@ -4810,2 +4810,3 @@
 case tok::kw___unaligned:
-  if (AttrReqs & AR_DeclspecAttributesParsed) {
+  // Allow __unaligned in function definition after a parameter list
+  if ((AttrReqs & AR_DeclspecAttributesParsed) ||

aaron.ballman wrote:
> 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?
It rather silently accepts the keyword in this position.


Comment at: lib/Parse/ParseDecl.cpp:4813
@@ -4812,1 +4812,3 @@
+  if ((AttrReqs & AR_DeclspecAttributesParsed) ||
+  (Tok.getKind() == tok::kw___unaligned)) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());

rnk wrote:
> This will allow __unaligned in a variety of other locations where we 
> shouldn't accept it.
Could you please help me with narrowing it down to the case I'm interested in?


http://reviews.llvm.org/D17709



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits