]> granicus.if.org Git - clang/commitdiff
Add support for MSVC __unaligned attribute. Necessary to parse MSVC headers in 64...
authorFrancois Pichet <pichet2000@gmail.com>
Thu, 18 Aug 2011 09:59:55 +0000 (09:59 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Thu, 18 Aug 2011 09:59:55 +0000 (09:59 +0000)
more info: http://msdn.microsoft.com/en-us/library/ms177389.aspx

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137935 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/TokenKinds.def
lib/Parse/ParseDecl.cpp
lib/Parse/ParseTentative.cpp
test/SemaCXX/MicrosoftExtensions.cpp

index d057559889a491fab3d1aa0372242b6048e4ef4c..95bfca446a5a9eecafe91060552a7ef2e14e669b 100644 (file)
@@ -405,6 +405,7 @@ KEYWORD(__stdcall                   , KEYALL)
 KEYWORD(__fastcall                  , KEYALL)
 KEYWORD(__thiscall                  , KEYALL)
 KEYWORD(__forceinline               , KEYALL)
+KEYWORD(__unaligned                 , KEYMS)
 
 // OpenCL-specific keywords
 KEYWORD(__kernel                    , KEYOPENCL)
index 2a95ecc7c7234d268e35f51f746056acc3cace43..9023b34fa9c9ba9a7cb40673842aa66ea6554f60 100644 (file)
@@ -302,7 +302,8 @@ void Parser::ParseMicrosoftTypeAttributes(ParsedAttributes &attrs) {
   // FIXME: Allow Sema to distinguish between these and real attributes!
   while (Tok.is(tok::kw___fastcall) || Tok.is(tok::kw___stdcall) ||
          Tok.is(tok::kw___thiscall) || Tok.is(tok::kw___cdecl)   ||
-         Tok.is(tok::kw___ptr64) || Tok.is(tok::kw___w64)) {
+         Tok.is(tok::kw___ptr64) || Tok.is(tok::kw___w64) ||
+         Tok.is(tok::kw___unaligned)) {
     IdentifierInfo *AttrName = Tok.getIdentifierInfo();
     SourceLocation AttrNameLoc = ConsumeToken();
     if (Tok.is(tok::kw___ptr64) || Tok.is(tok::kw___w64))
@@ -1726,6 +1727,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
     case tok::kw___stdcall:
     case tok::kw___fastcall:
     case tok::kw___thiscall:
+    case tok::kw___unaligned:
       ParseMicrosoftTypeAttributes(DS.getAttributes());
       continue;
 
@@ -2274,6 +2276,7 @@ bool Parser::ParseOptionalTypeSpecifier(DeclSpec &DS, bool& isInvalid,
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___unaligned:
     ParseMicrosoftTypeAttributes(DS.getAttributes());
     return true;
 
@@ -2982,6 +2985,7 @@ bool Parser::isTypeSpecifierQualifier() {
   case tok::kw___w64:
   case tok::kw___ptr64:
   case tok::kw___pascal:
+  case tok::kw___unaligned:
 
   case tok::kw___private:
   case tok::kw___local:
@@ -3129,6 +3133,7 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) {
   case tok::kw___ptr64:
   case tok::kw___forceinline:
   case tok::kw___pascal:
+  case tok::kw___unaligned:
 
   case tok::kw___private:
   case tok::kw___local:
@@ -3264,6 +3269,7 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS,
     case tok::kw___stdcall:
     case tok::kw___fastcall:
     case tok::kw___thiscall:
+    case tok::kw___unaligned:
       if (VendorAttributesAllowed) {
         ParseMicrosoftTypeAttributes(DS.getAttributes());
         continue;
@@ -3676,7 +3682,8 @@ void Parser::ParseParenDeclarator(Declarator &D) {
   // Eat any Microsoft extensions.
   if  (Tok.is(tok::kw___cdecl) || Tok.is(tok::kw___stdcall) ||
        Tok.is(tok::kw___thiscall) || Tok.is(tok::kw___fastcall) ||
-       Tok.is(tok::kw___w64) || Tok.is(tok::kw___ptr64)) {
+       Tok.is(tok::kw___w64) || Tok.is(tok::kw___ptr64) ||
+       Tok.is(tok::kw___unaligned)) {
     ParseMicrosoftTypeAttributes(attrs);
   }
   // Eat any Borland extensions.
index 3f245a376cc36a72a6a62e917b96af1ee518eb06..e354f57b70bf6d17a4dcb2417a918e4d62034327 100644 (file)
@@ -552,7 +552,8 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract,
           Tok.is(tok::kw___cdecl) ||
           Tok.is(tok::kw___stdcall) ||
           Tok.is(tok::kw___fastcall) ||
-          Tok.is(tok::kw___thiscall))
+          Tok.is(tok::kw___thiscall) ||
+          Tok.is(tok::kw___unaligned))\r
         return TPResult::True(); // attributes indicate declaration
       TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
       if (TPR != TPResult::Ambiguous())
@@ -711,6 +712,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) {
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___unaligned:\r
   case tok::kw___vector:
   case tok::kw___pixel:
     return TPResult::False();
@@ -903,6 +905,7 @@ Parser::TPResult Parser::isCXXDeclarationSpecifier() {
   case tok::kw___w64:
   case tok::kw___ptr64:
   case tok::kw___forceinline:
+  case tok::kw___unaligned:\r
     return TPResult::True();
 
     // Borland
index 9b03feb5390951eb9093a3b4a201ea07c12b8fb4..db6d30a9c63bcdde15cc566af068c3741029fb32 100644 (file)
@@ -81,6 +81,10 @@ struct M {
     float __stdcall subtractP(); 
 };
 
+// __unaligned handling
+typedef char __unaligned *aligned_type;
+
+
 template<typename T> void h1(T (__stdcall M::* const )()) { }
 
 void m1() {