diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 93d49b0563be..4df7cfd5befd 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -288,20 +288,16 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI, else if (!LangOpts.GNUMode && LangOpts.Digraphs) Builder.defineMacro("__STDC_VERSION__", "199409L"); } else { - if (LangOpts.GNUMode) - Builder.defineMacro("__cplusplus"); - 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. - else - Builder.defineMacro("__cplusplus", "199711L"); - } + // C++11 [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. + else + Builder.defineMacro("__cplusplus", "199711L"); } if (LangOpts.ObjC1) diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 0505fffedde4..4d5c36c759b6 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -62,12 +62,21 @@ // // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -check-prefix FREESTANDING %s // FREESTANDING:#define __STDC_HOSTED__ 0 -// +// +// +// RUN: %clang_cc1 -x c++ -std=gnu++11 -E -dM < /dev/null | FileCheck -check-prefix GXX11 %s +// +// GXX11:#define __GNUG__ +// GXX11:#define __GXX_WEAK__ 1 +// GXX11:#define __cplusplus 201103L +// GXX11:#define __private_extern__ extern +// +// // RUN: %clang_cc1 -x c++ -std=gnu++98 -E -dM < /dev/null | FileCheck -check-prefix GXX98 %s // // GXX98:#define __GNUG__ // GXX98:#define __GXX_WEAK__ 1 -// GXX98:#define __cplusplus 1 +// GXX98:#define __cplusplus 199711L // GXX98:#define __private_extern__ extern // //