From b4489162b6bb670825f9531286b2c231fb0d98aa Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Sat, 10 Mar 2012 22:21:14 +0000 Subject: [PATCH] No longer defining GNUC mode when compiling for Microsoft compatibility. This allows people's cross-platform compiler-specific macros to work properly. llvm-svn: 152512 --- clang/lib/Frontend/InitPreprocessor.cpp | 13 ++++++++----- clang/test/Preprocessor/predefined-macros.c | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 2052a3a6b1f6..2caab7c5dd36 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -319,11 +319,14 @@ static void InitializePredefinedMacros(const TargetInfo &TI, + getClangFullRepositoryVersion() + ")\""); #undef TOSTR #undef TOSTR2 - // Currently claim to be compatible with GCC 4.2.1-5621. - Builder.defineMacro("__GNUC_MINOR__", "2"); - Builder.defineMacro("__GNUC_PATCHLEVEL__", "1"); - Builder.defineMacro("__GNUC__", "4"); - Builder.defineMacro("__GXX_ABI_VERSION", "1002"); + if (!LangOpts.MicrosoftMode) { + // Currently claim to be compatible with GCC 4.2.1-5621, but only if we're + // not compiling for MSVC compatibility + Builder.defineMacro("__GNUC_MINOR__", "2"); + Builder.defineMacro("__GNUC_PATCHLEVEL__", "1"); + Builder.defineMacro("__GNUC__", "4"); + Builder.defineMacro("__GXX_ABI_VERSION", "1002"); + } // Define macros for the C11 / C++11 memory orderings Builder.defineMacro("__ATOMIC_RELAXED", "0"); diff --git a/clang/test/Preprocessor/predefined-macros.c b/clang/test/Preprocessor/predefined-macros.c index 5b03872c1f67..8ec4d7ecf67a 100644 --- a/clang/test/Preprocessor/predefined-macros.c +++ b/clang/test/Preprocessor/predefined-macros.c @@ -8,6 +8,7 @@ // CHECK-MS: #define _M_IX86 600 // CHECK-MS: #define _M_IX86_FP // CHECK-MS: #define _WIN32 1 +// CHECK-MS-NOT: #define __GNUC__ // // RUN: %clang_cc1 %s -E -dM -ffast-math -o - \ // RUN: | FileCheck %s --check-prefix=CHECK-FAST-MATH