]> granicus.if.org Git - clang/commitdiff
Upgrade Microsoft's __int8, __int16, __int32 and __int64 types from builtin defines...
authorFrancois Pichet <pichet2000@gmail.com>
Thu, 28 Apr 2011 01:59:37 +0000 (01:59 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Thu, 28 Apr 2011 01:59:37 +0000 (01:59 +0000)
Otherwise statements like:
  __int64 var = __int64(0);

would be expanded to:
  long long var = long long(0);

and fail to compile.

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

include/clang/Basic/TokenKinds.def
lib/Frontend/InitPreprocessor.cpp
lib/Parse/ParseDecl.cpp
lib/Parse/ParseExpr.cpp
lib/Parse/ParseExprCXX.cpp
lib/Parse/ParseTentative.cpp
test/Parser/MicrosoftExtensions.cpp
test/Preprocessor/init.c

index 1d121a1596fce6b435fa560dbbcc2baffdcc3ac8..f9d1f4ef158e2cd2257dc71be2d49f390b4622c7 100644 (file)
@@ -450,6 +450,10 @@ KEYWORD(__try                     , KEYMS | KEYBORLAND)
 KEYWORD(__except                  , KEYMS | KEYBORLAND)
 KEYWORD(__finally                 , KEYMS | KEYBORLAND)
 KEYWORD(__leave                   , KEYMS | KEYBORLAND)
+KEYWORD(__int64                   , KEYMS)
+ALIAS("__int8"       , char       , KEYMS)
+ALIAS("__int16"      , short      , KEYMS)
+ALIAS("__int32"      , int        , KEYMS)
 ALIAS("_asm"         , asm        , KEYMS)
 ALIAS("_cdecl"       , __cdecl    , KEYMS | KEYBORLAND)
 ALIAS("_fastcall"    , __fastcall , KEYMS | KEYBORLAND)
index 58379d3459fa3cbdb8f1268895b8d0800b243048..abe251d67df20ba5197a107a54f6731a6c2785eb 100644 (file)
@@ -335,12 +335,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
   }
 
   if (LangOpts.Microsoft) {
-    // Filter out some microsoft extensions when trying to parse in ms-compat
-    // mode.
-    Builder.defineMacro("__int8", "__INT8_TYPE__");
-    Builder.defineMacro("__int16", "__INT16_TYPE__");
-    Builder.defineMacro("__int32", "__INT32_TYPE__");
-    Builder.defineMacro("__int64", "__INT64_TYPE__");
     // Both __PRETTY_FUNCTION__ and __FUNCTION__ are GCC extensions, however
     // VC++ appears to only like __FUNCTION__.
     Builder.defineMacro("__PRETTY_FUNCTION__", "__FUNCTION__");
index dabb7565cb07b29373a9673c71cd1d895aa50169..24a487c89c35df3e328ff7550f929de400b4a9a6 100644 (file)
@@ -171,6 +171,7 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs,
           case tok::kw_short:
           case tok::kw_int:
           case tok::kw_long:
+          case tok::kw___int64:
           case tok::kw_signed:
           case tok::kw_unsigned:
           case tok::kw_float:
@@ -1688,6 +1689,10 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
         isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, Loc, PrevSpec,
                                         DiagID);
       break;
+    case tok::kw___int64:
+        isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, Loc, PrevSpec,
+                                        DiagID);
+      break;
     case tok::kw_signed:
       isInvalid = DS.SetTypeSpecSign(DeclSpec::TSS_signed, Loc, PrevSpec,
                                      DiagID);
@@ -1986,6 +1991,10 @@ bool Parser::ParseOptionalTypeSpecifier(DeclSpec &DS, bool& isInvalid,
       isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, Loc, PrevSpec,
                                       DiagID);
     break;
+  case tok::kw___int64:
+      isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, Loc, PrevSpec,
+                                      DiagID);
+    break;
   case tok::kw_signed:
     isInvalid = DS.SetTypeSpecSign(DeclSpec::TSS_signed, Loc, PrevSpec, DiagID);
     break;
@@ -2704,6 +2713,7 @@ bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const {
     // type-specifiers
   case tok::kw_short:
   case tok::kw_long:
+  case tok::kw___int64:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw__Complex:
@@ -2772,6 +2782,7 @@ bool Parser::isTypeSpecifierQualifier() {
     // type-specifiers
   case tok::kw_short:
   case tok::kw_long:
+  case tok::kw___int64:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw__Complex:
@@ -2895,6 +2906,7 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) {
     // type-specifiers
   case tok::kw_short:
   case tok::kw_long:
+  case tok::kw___int64:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw__Complex:
index 8b9e5e752b023ea0cedd7ea27c1a6d117d83056a..91fe1e1935e9dbae544e1a8f49a170f1ccee05ce 100644 (file)
@@ -903,6 +903,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
   case tok::kw_short:
   case tok::kw_int:
   case tok::kw_long:
+  case tok::kw___int64:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw_float:
index 50752058cdffc43d97275528b7027039941ceb27..ca3242ba46f1b550b50a35ea788b5c9f50e0b408 100644 (file)
@@ -945,6 +945,7 @@ bool Parser::isCXXSimpleTypeSpecifier() const {
   case tok::annot_typename:
   case tok::kw_short:
   case tok::kw_long:
+  case tok::kw___int64:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw_void:
@@ -1036,6 +1037,9 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
   case tok::kw_long:
     DS.SetTypeSpecWidth(DeclSpec::TSW_long, Loc, PrevSpec, DiagID);
     break;
+  case tok::kw___int64:
+    DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, Loc, PrevSpec, DiagID);
+    break;
   case tok::kw_signed:
     DS.SetTypeSpecSign(DeclSpec::TSS_signed, Loc, PrevSpec, DiagID);
     break;
index 618c3e2bd4de504194d77c469d7073367981d061..1c4e2b3ddc8b2a8d0b0ba4b54c0126d6632621d9 100644 (file)
@@ -676,6 +676,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) {
   case tok::kw_float:
   case tok::kw_int:
   case tok::kw_long:
+  case tok::kw___int64:
   case tok::kw_restrict:
   case tok::kw_short:
   case tok::kw_signed:
@@ -971,6 +972,7 @@ Parser::TPResult Parser::isCXXDeclarationSpecifier() {
   case tok::kw_short:
   case tok::kw_int:
   case tok::kw_long:
+  case tok::kw___int64:
   case tok::kw_signed:
   case tok::kw_unsigned:
   case tok::kw_float:
index cf833039ededc476bd7382d04f5f52a269e9692a..a5d2d513b12b1bb0c8d695db05723f27ee8d8bcf 100644 (file)
@@ -151,4 +151,6 @@ __interface MicrosoftInterface;
 __interface MicrosoftInterface {
    virtual void foo1() = 0;
    virtual void foo2() = 0;
-};
\ No newline at end of file
+};
+
+__int64 x7 = __int64(0);
index a070f9a0b1172e72d92f81713e10712d789b5733..b0515b3bba3c35f6692269a2d565d330741da0af 100644 (file)
 //
 // MSEXT-NOT:#define __STDC__
 // MSEXT:#define _INTEGRAL_MAX_BITS 64
-// MSEXT:#define __int16 __INT16_TYPE__
-// MSEXT:#define __int32 __INT32_TYPE__
-// MSEXT:#define __int64 __INT64_TYPE__
-// MSEXT:#define __int8 __INT8_TYPE__
 //
 // 
 // RUN: %clang_cc1 -x objective-c -E -dM < /dev/null | FileCheck -check-prefix OBJC %s