[PATCH] Allow _MSC_EXTENSIONS macro on non-Windows targets
Yunzhong Gao
Yunzhong_Gao at playstation.sony.com
Mon Mar 10 15:46:10 PDT 2014
ygao added you to the CC list for the revision "Allow _MSC_EXTENSIONS macro on non-Windows targets".
Hi,
The -fms-extensions option affects a number of subtle front-end C/C++
behaviors, and it would be useful to use the _MSC_EXTENSIONS macro
in the codes. Are there objections to making -fms-extensions define this
macro even if the triple does not define a Windows target? It should make
life easier if anyone needs to port their Windows codes to elsewhere.
- Gao
http://llvm-reviews.chandlerc.com/D3034
Files:
lib/Basic/Targets.cpp
lib/Frontend/InitPreprocessor.cpp
test/Preprocessor/predefined-macros.c
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -571,8 +571,6 @@
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");
Index: lib/Frontend/InitPreprocessor.cpp
===================================================================
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -508,6 +508,8 @@
}
if (LangOpts.MicrosoftExt) {
+ Builder.defineMacro("_MSC_EXTENSIONS");
+
// Both __PRETTY_FUNCTION__ and __FUNCTION__ are GCC extensions, however
// VC++ appears to only like __FUNCTION__.
Builder.defineMacro("__PRETTY_FUNCTION__", "__FUNCTION__");
Index: test/Preprocessor/predefined-macros.c
===================================================================
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -10,6 +10,9 @@
// CHECK-MS: #define _WIN32 1
// CHECK-MS-NOT: #define __GNUC__
//
+// RUN: %clang_cc1 %s -E -dM -fms-extensions -o - | FileCheck %s --check-prefix=CHECK-MS-EXT
+// CHECK-MS-EXT: #define _MSC_EXTENSIONS 1
+//
// RUN: %clang_cc1 %s -E -dM -ffast-math -o - \
// RUN: | FileCheck %s --check-prefix=CHECK-FAST-MATH
// CHECK-FAST-MATH: #define __FAST_MATH__
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3034.1.patch
Type: text/x-patch
Size: 1530 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140310/9a2c425b/attachment.bin>
More information about the cfe-commits
mailing list