From: Douglas Gregor Date: Mon, 20 Jun 2011 15:00:58 +0000 (+0000) Subject: Define __cplusplus to 201103L when in (non-GNU) C++0x mode. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0678899e0d619df03eae2e2d43c3fe1fa958d03a;p=clang Define __cplusplus to 201103L when in (non-GNU) C++0x mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133437 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index e1c394ea75..aefd1ea5b8 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -359,11 +359,18 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI, } else { if (LangOpts.GNUMode) Builder.defineMacro("__cplusplus"); - else - // C++ [cpp.predefined]p1: + else { + // C++0x [cpp.predefined]p1: + // The name_ _cplusplus is defined to the value 201103L when compiling a + // C++ translation unit. + if (LangOpts.CPlusPlus0x) + Builder.defineMacro("__cplusplus", "201103L"); + // C++03 [cpp.predefined]p1: // The name_ _cplusplus is defined to the value 199711L when compiling a // C++ translation unit. - Builder.defineMacro("__cplusplus", "199711L"); + else + Builder.defineMacro("__cplusplus", "199711L"); + } } if (LangOpts.ObjC1) diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index b0515b3bba..f0920c9ded 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -15,7 +15,7 @@ // CXX0X:#define __GXX_EXPERIMENTAL_CXX0X__ 1 // CXX0X:#define __GXX_RTTI 1 // CXX0X:#define __GXX_WEAK__ 1 -// CXX0X:#define __cplusplus 199711L +// CXX0X:#define __cplusplus 201103L // CXX0X:#define __private_extern__ extern // //