From 0e680249cd3721a9ece64400fd4b58d6f3c4b8c4 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 16 Apr 2014 19:47:06 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206413 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets.cpp | 13 ------------- lib/Frontend/InitPreprocessor.cpp | 12 ++++++++++++ test/Preprocessor/microsoft-ext.c | 8 ++++++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 2cf90701ed..1558a752c3 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -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"); } diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index a86fe51426..95d9e510f8 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -507,7 +507,19 @@ static void InitializePredefinedMacros(const TargetInfo &TI, 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"); diff --git a/test/Preprocessor/microsoft-ext.c b/test/Preprocessor/microsoft-ext.c index b03f677542..541cd4387d 100644 --- a/test/Preprocessor/microsoft-ext.c +++ b/test/Preprocessor/microsoft-ext.c @@ -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} -- 2.40.0