diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-05-07 19:32:56 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-05-07 19:32:56 +0000 |
| commit | 0a715429b9833f956e022099d5da64ff719df5ff (patch) | |
| tree | 9ca6cc2b2dc3e9f3a4de9131df10e5cb4cfb3a5a /clang/lib | |
| parent | e9ea0da82e0db315e62fe3b3d5e3580d3669d341 (diff) | |
| download | bcm5719-llvm-0a715429b9833f956e022099d5da64ff719df5ff.tar.gz bcm5719-llvm-0a715429b9833f956e022099d5da64ff719df5ff.zip | |
C++1y: Update __cplusplus to temporary value 201305L to allow detection of provisional C++1y support.
Add __has_feature and __has_extension checks for C++1y features (based on the provisional names from
the C++ features study group), and update documentation to match.
llvm-svn: 181342
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 14 |
2 files changed, 17 insertions, 4 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 25cfac63233..dc3ab53eda0 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -302,12 +302,13 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI, else if (!LangOpts.GNUMode && LangOpts.Digraphs) Builder.defineMacro("__STDC_VERSION__", "199409L"); } else { - // FIXME: LangOpts.CPlusPlus1y - + // FIXME: Use the right value for __cplusplus for C++1y once one is chosen. + if (LangOpts.CPlusPlus1y) + Builder.defineMacro("__cplusplus", "201305L"); // C++11 [cpp.predefined]p1: // The name __cplusplus is defined to the value 201103L when compiling a // C++ translation unit. - if (LangOpts.CPlusPlus11) + else if (LangOpts.CPlusPlus11) Builder.defineMacro("__cplusplus", "201103L"); // C++03 [cpp.predefined]p1: // The name __cplusplus is defined to the value 199711L when compiling a diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 167823358af..24c6217ced2 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -792,6 +792,16 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { .Case("cxx_unrestricted_unions", LangOpts.CPlusPlus11) .Case("cxx_user_literals", LangOpts.CPlusPlus11) .Case("cxx_variadic_templates", LangOpts.CPlusPlus11) + // C++1y features + .Case("cxx_binary_literals", LangOpts.CPlusPlus1y) + //.Case("cxx_contextual_conversions", LangOpts.CPlusPlus1y) + //.Case("cxx_generalized_capture", LangOpts.CPlusPlus1y) + //.Case("cxx_generic_lambda", LangOpts.CPlusPlus1y) + //.Case("cxx_relaxed_constexpr", LangOpts.CPlusPlus1y) + //.Case("cxx_return_type_deduction", LangOpts.CPlusPlus1y) + //.Case("cxx_runtime_array", LangOpts.CPlusPlus1y) + .Case("cxx_aggregate_nsdmi", LangOpts.CPlusPlus1y) + //.Case("cxx_variable_templates", LangOpts.CPlusPlus1y) // Type traits .Case("has_nothrow_assign", LangOpts.CPlusPlus) .Case("has_nothrow_copy", LangOpts.CPlusPlus) @@ -852,7 +862,7 @@ static bool HasExtension(const Preprocessor &PP, const IdentifierInfo *II) { .Case("c_atomic", true) .Case("c_generic_selections", true) .Case("c_static_assert", true) - // C++0x features supported by other languages as extensions. + // C++11 features supported by other languages as extensions. .Case("cxx_atomic", LangOpts.CPlusPlus) .Case("cxx_deleted_functions", LangOpts.CPlusPlus) .Case("cxx_explicit_conversions", LangOpts.CPlusPlus) @@ -863,6 +873,8 @@ static bool HasExtension(const Preprocessor &PP, const IdentifierInfo *II) { .Case("cxx_range_for", LangOpts.CPlusPlus) .Case("cxx_reference_qualified_functions", LangOpts.CPlusPlus) .Case("cxx_rvalue_references", LangOpts.CPlusPlus) + // C++1y features supported by other languages as extensions. + .Case("cxx_binary_literals", true) .Default(false); } |

