From 2af22083a60e60114e34418c4a6ed8762e40eb86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Tue, 25 Apr 2017 17:30:07 +0200 Subject: [PATCH] Add support for C++17 parsing with cpp_1z option Note: It is currently experimental. --- include/cppast/compile_config.hpp | 6 +++++- src/libclang/libclang_parser.cpp | 6 ++++++ tool/main.cpp | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/cppast/compile_config.hpp b/include/cppast/compile_config.hpp index 9473350..3e17ad6 100644 --- a/include/cppast/compile_config.hpp +++ b/include/cppast/compile_config.hpp @@ -23,7 +23,9 @@ namespace cppast cpp_11, cpp_14, - cpp_latest = cpp_standard::cpp_14, + cpp_1z, //< Upcoming C++17 (experimental). + + cpp_latest = cpp_standard::cpp_14, //< The latest supported C++ standard. }; /// \returns A human readable string representing the option, @@ -40,6 +42,8 @@ namespace cppast return "c++11"; case cpp_standard::cpp_14: return "c++14"; + case cpp_standard::cpp_1z: + return "c++1z"; } DEBUG_UNREACHABLE(detail::assert_handler{}); diff --git a/src/libclang/libclang_parser.cpp b/src/libclang/libclang_parser.cpp index a35fbbf..3bd900f 100644 --- a/src/libclang/libclang_parser.cpp +++ b/src/libclang/libclang_parser.cpp @@ -86,6 +86,12 @@ void libclang_compile_config::do_set_flags(cpp_standard standard, compile_flags else add_flag("-std=c++14"); break; + case cpp_standard::cpp_1z: + if (flags & compile_flag::gnu_extensions) + add_flag("-std=gnu++1z"); + else + add_flag("-std=c++1z"); + break; } if (flags & compile_flag::ms_compatibility) diff --git a/tool/main.cpp b/tool/main.cpp index c33d8a7..45558b1 100644 --- a/tool/main.cpp +++ b/tool/main.cpp @@ -210,7 +210,7 @@ int main(int argc, char* argv[]) ("file", "the file that is being parsed (last positional argument)", cxxopts::value()); options.add_options("compilation") - ("std", "set the C++ standard (c++98, c++03, c++11, c++14)", + ("std", "set the C++ standard (c++98, c++03, c++11, c++14, c++1z (experimental))", cxxopts::value()->default_value(cppast::to_string(cppast::cpp_standard::cpp_latest))) ("I,include_directory", "add directory to include search path", cxxopts::value>()) @@ -276,6 +276,8 @@ int main(int argc, char* argv[]) config.set_flags(cppast::cpp_standard::cpp_11, flags); else if (options["std"].as() == "c++14") config.set_flags(cppast::cpp_standard::cpp_14, flags); + else if (options["std"].as() == "c++1z") + config.set_flags(cppast::cpp_standard::cpp_1z, flags); else { print_error("invalid value '" + options["std"].as() + "' for std flag");