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 e1c394e..aefd1ea 100644
--- a/lib/Frontend/InitPreprocessor.cpp
+++ b/lib/Frontend/InitPreprocessor.cpp
@@ -359,11 +359,18 @@
   } 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 b0515b3..f0920c9 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
 //
 //