Index: External/CUDA/CMakeLists.txt =================================================================== --- External/CUDA/CMakeLists.txt +++ External/CUDA/CMakeLists.txt @@ -316,10 +316,6 @@ set(_Std_LDFLAGS -std=${_Std}) foreach(_GccPath IN LISTS GCC_PATHS) get_version(_GccVersion ${_GccPath}) - # libstdc++ seems not to support C++14 before version 5.0. - if(${_Std} STREQUAL "c++14" AND ${_GccVersion} VERSION_LESS "5.0") - continue() - endif() set(_Gcc_Suffix "libstdc++-${_GccVersion}") # Tell clang to use libstdc++ and where to find it. set(_Stdlib_CPPFLAGS -stdlib=libstdc++ -gcc-toolchain ${_GccPath}) @@ -327,6 +323,15 @@ # Add libstdc++ as link dependency. set(_Stdlib_Libs libstdcxx-${_GccVersion}) + # libstdc++ seems not to support C++14 before version 5.0. We still + # want to run in C++14 mode with old libstdc++s to test compiler C++14 + # with stdlib C++11, but we add a -D so that our tests can detect this. + if (${_GccVersion} VERSION_LESS "5.0") + list(APPEND _Stdlib_CPPFLAGS -DSTDLIB_VERSION=2011) + else() + list(APPEND _Stdlib_CPPFLAGS -DSTDLIB_VERSION=2014) + endif() + create_cuda_test_variant(${_Std} "${_Cuda_Suffix}-${_Std_Suffix}-${_Gcc_Suffix}") endforeach() @@ -335,7 +340,7 @@ # Tell clang to use libc++ # We also need to add compiler's include path for cxxabi.h get_filename_component(_compiler_path ${CMAKE_CXX_COMPILER} DIRECTORY) - set(_Stdlib_CPPFLAGS -stdlib=libc++ -I${_compiler_path}/../include/c++-build) + set(_Stdlib_CPPFLAGS -stdlib=libc++ -I${_compiler_path}/../include/c++-build -DSTDLIB_VERSION=2017) set(_Stdlib_LDFLAGS -stdlib=libc++) set(_Stdlib_Libs libcxx) create_cuda_test_variant(${_Std} "${_Cuda_Suffix}-${_Std_Suffix}-libc++") Index: External/CUDA/algorithm.cu =================================================================== --- External/CUDA/algorithm.cu +++ External/CUDA/algorithm.cu @@ -27,7 +27,7 @@ // initializer_lists until C++14, when it gets these for free from the standard // library (because they're constexpr). __device__ void cpp14_tests() { -#if __cplusplus >= 201402L +#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014 assert(std::greater()(1, 0)); assert(std::min({5, 1, 10}) == 1); assert(std::max({5, 1, 10}, std::less()) == 10); Index: External/CUDA/cmath.cu =================================================================== --- External/CUDA/cmath.cu +++ External/CUDA/cmath.cu @@ -1145,7 +1145,7 @@ assert(std::hypot(3.f, 4.) == 5); assert(std::hypot(3.f, 4.f) == 5); -#if TEST_STD_VER > 14 +#if __cplusplus >= 201703L && STDLIB_VERSION >= 2017 static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); @@ -1158,8 +1158,8 @@ static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - assert(std::hypot(2,3,6) == 7); - assert(std::hypot(1,4,8) == 9); + assert(std::hypot(2, 3, 6) == 7); + assert(std::hypot(1, 4, 8) == 9); #endif } Index: External/CUDA/complex.cu =================================================================== --- External/CUDA/complex.cu +++ External/CUDA/complex.cu @@ -7,10 +7,6 @@ // //===----------------------------------------------------------------------===// -#include -#include -#include - // These are loosely adapted from libc++'s tests. In general, we don't care a // ton about verifying the return types or results we get, on the assumption // that our standard library is correct. But we care deeply about calling every @@ -19,13 +15,21 @@ // We do care about the results of complex multiplication / division, since // these use code we've written. +#include + // These tests are pretty annoying to write without C++11, so we require that. // In addition, these tests currently don't compile with libc++, because of the // issue in https://reviews.llvm.org/D25403. // // TODO: Once that issue is resolved, take out !defined(_LIBCPP_VERSION) here. -#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) +// +// In addition, these tests don't work in C++14 mode with pre-C++14 versions of +// libstdc++ (compile errors in ). +#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \ + (__cplusplus < 201402L || STDLIB_VERSION >= 2014) +#include +#include #include template @@ -69,7 +73,7 @@ } __device__ void test_literals() { -#if __cplusplus >= 201402L +#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014 using namespace std::literals::complex_literals; {