diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -110,6 +110,9 @@ Modified Compiler Flags ----------------------- +- ``-fms-extensions`` now defines the ``_MSC_EXTENSIONS`` macro regardless of + whether or not the ``-fms-compatibility`` flag is set and regardless of the + target triple. Removed Compiler Flags ------------------------- diff --git a/clang/lib/Basic/Targets/OSTargets.cpp b/clang/lib/Basic/Targets/OSTargets.cpp --- a/clang/lib/Basic/Targets/OSTargets.cpp +++ b/clang/lib/Basic/Targets/OSTargets.cpp @@ -226,16 +226,6 @@ } } - 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"); - } - } - if (!Opts.MSVolatile) Builder.defineMacro("_ISO_VOLATILE"); diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -926,11 +926,19 @@ Builder.defineMacro("__private_extern__", "extern"); if (LangOpts.MicrosoftExt) { + Builder.defineMacro("_MSC_EXTENSIONS"); + if (LangOpts.WChar) { // wchar_t supported as a keyword. Builder.defineMacro("_WCHAR_T_DEFINED"); Builder.defineMacro("_NATIVE_WCHAR_T_DEFINED"); } + + if (LangOpts.CPlusPlus11) { + Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED"); + Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED"); + Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED"); + } } // Macros to help identify the narrow and wide character sets diff --git a/clang/test/Preprocessor/predefined-win-macros.c b/clang/test/Preprocessor/predefined-win-macros.c --- a/clang/test/Preprocessor/predefined-win-macros.c +++ b/clang/test/Preprocessor/predefined-win-macros.c @@ -120,6 +120,11 @@ // CHECK-AMD64-MINGW: #define _WIN32 1 // CHECK-AMD64-MINGW: #define _WIN64 1 +// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - -fms-extensions \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW-MSE + +// CHECK-AMD64-MINGW-MSE: #define _MSC_EXTENSIONS 1 + // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \ // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW