Hi David, The attached patch fixes __declspec parsing after the class specification.
Verified against MSVC. Alp. -- http://www.nuanti.com the browser experts
commit a6f855750215e1a6652ab6a3bc6d551ca030101b Author: Alp Toker <[email protected]> Date: Sun Nov 24 07:09:59 2013 +0000 Parse Microsoft __declspec appearing after class body MSVC applies these to the object only. Handling differs from ordinary attributes appearing in the same place, so add a Sema test to make sure we get it right. diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index d2d9b22..32e151c 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1021,6 +1021,7 @@ bool Parser::isValidAfterTypeSpecifier(bool CouldBeBitfield) { case tok::l_paren: // struct foo {...} ( x); case tok::comma: // __builtin_offsetof(struct foo{...} , case tok::kw_operator: // struct foo operator ++() {...} + case tok::kw___declspec: // struct foo {...} __declspec(...) return true; case tok::colon: return CouldBeBitfield; // enum E { ... } : 2; diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp index c5b45a2..69fefc2 100644 --- a/test/SemaCXX/MicrosoftExtensions.cpp +++ b/test/SemaCXX/MicrosoftExtensions.cpp @@ -410,3 +410,11 @@ struct SealedType sealed : SomeBase { // expected-error@+1 {{base 'SealedType' is marked 'sealed'}} struct InheritFromSealed : SealedType {}; + +void AfterClassBody() { + struct __declspec(align(4)) S {} __declspec(align(8)) s1; + S s2; + _Static_assert(__alignof(S) == 4, ""); + _Static_assert(__alignof(s1) == 8, ""); + _Static_assert(__alignof(s2) == 4, ""); +}
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
