From 56ea94e09d0aa6a80e25d89ce92967dcb51f134e Mon Sep 17 00:00:00 2001
From: David Majnemer <david.majnemer@gmail.com>
Date: Tue, 14 Jan 2014 06:19:35 +0000
Subject: [PATCH] Sema: Predefine size_t in MSVC Compatibility mode

MSVC defines size_t without any explicit declarations.  This change
allows us to be compatible with TUs that depend on this declaration
appearing from nowhere.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199190 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Sema/Sema.cpp                       | 2 ++
 test/SemaCXX/MicrosoftCompatibility.cpp | 1 +
 2 files changed, 3 insertions(+)

diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index c824921a4f1..a6d3e322d0f 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -182,6 +182,8 @@ void Sema::Initialize() {
     if (IdResolver.begin(&Context.Idents.get("type_info")) == IdResolver.end())
       PushOnScopeChains(Context.buildImplicitRecord("type_info", TTK_Class),
                         TUScope);
+
+    addImplicitTypedef("size_t", Context.getSizeType());
   }
 
   // Initialize predefined OpenCL types.
diff --git a/test/SemaCXX/MicrosoftCompatibility.cpp b/test/SemaCXX/MicrosoftCompatibility.cpp
index a914169bb68..1f27deb0ee1 100644
--- a/test/SemaCXX/MicrosoftCompatibility.cpp
+++ b/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -24,6 +24,7 @@ void test()
 namespace ms_predefined_types {
   // ::type_info is a built-in forward class declaration.
   void f(const type_info &a);
+  void f(size_t);
 }
 
 
-- 
GitLab