r206413 - Move -fms-extensions predefined macros into InitPreprocessor

Reid Kleckner reid at kleckner.net
Wed Apr 16 12:47:06 PDT 2014


Author: rnk
Date: Wed Apr 16 14:47:06 2014
New Revision: 206413

URL: http://llvm.org/viewvc/llvm-project?rev=206413&view=rev
Log:
Move -fms-extensions predefined macros into InitPreprocessor

If someone on Linux asks for -fms-extensions, there's no reason not to
define the feature test macros that MSVC defines.

Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp
    cfe/trunk/test/Preprocessor/microsoft-ext.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=206413&r1=206412&r2=206413&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Apr 16 14:47:06 2014
@@ -577,19 +577,6 @@ protected:
     if (Opts.POSIXThreads)
       Builder.defineMacro("_MT");
 
-    if (Opts.MSCVersion != 0)
-      Builder.defineMacro("_MSC_VER", Twine(Opts.MSCVersion));
-
-    if (Opts.MicrosoftExt) {
-      Builder.defineMacro("_MSC_EXTENSIONS");
-
-      if (Opts.CPlusPlus11) {
-        Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED");
-        Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED");
-        Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED");
-      }
-    }
-
     Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
   }
 

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=206413&r1=206412&r2=206413&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Apr 16 14:47:06 2014
@@ -507,7 +507,19 @@ static void InitializePredefinedMacros(c
     Builder.defineMacro("__private_extern__", "extern");
   }
 
+  if (LangOpts.MSCVersion != 0)
+    Builder.defineMacro("_MSC_VER", Twine(LangOpts.MSCVersion));
+
   if (LangOpts.MicrosoftExt) {
+    // Define feature support macros that MSVC provides.
+    Builder.defineMacro("_MSC_EXTENSIONS");
+
+    if (LangOpts.CPlusPlus11) {
+      Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED");
+      Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED");
+      Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED");
+    }
+
     if (LangOpts.WChar) {
       // wchar_t supported as a keyword.
       Builder.defineMacro("_WCHAR_T_DEFINED");

Modified: cfe/trunk/test/Preprocessor/microsoft-ext.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/microsoft-ext.c?rev=206413&r1=206412&r2=206413&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/microsoft-ext.c (original)
+++ cfe/trunk/test/Preprocessor/microsoft-ext.c Wed Apr 16 14:47:06 2014
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -E -fms-compatibility %s -o %t
-// RUN: FileCheck %s < %t
+// RUN: %clang_cc1 -triple i686-pc-win32 -E -fms-extensions -fms-compatibility %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-linux-gnu -E -fms-extensions -fms-compatibility %s -o - | FileCheck %s
+
+#ifndef _MSC_EXTENSIONS
+# error "_MSC_EXTENSIONS not defined with -fms-extensions"
+#endif
 
 # define M2(x, y) x + y
 # define P(x, y) {x, y}





More information about the cfe-commits mailing list