This revision was automatically updated to reflect the committed changes.
Closed by commit rL332659: [test-suite] Test CUDA in C++14 mode with C++11 
stdlibs. (authored by jlebar, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46994?vs=147225&id=147383#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46994

Files:
  test-suite/trunk/External/CUDA/CMakeLists.txt
  test-suite/trunk/External/CUDA/algorithm.cu
  test-suite/trunk/External/CUDA/cmath.cu
  test-suite/trunk/External/CUDA/complex.cu

Index: test-suite/trunk/External/CUDA/complex.cu
===================================================================
--- test-suite/trunk/External/CUDA/complex.cu
+++ test-suite/trunk/External/CUDA/complex.cu
@@ -7,25 +7,29 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <assert.h>
-#include <stdio.h>
-#include <complex>
-
 // 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
 // overload of every function (so that we verify that everything compiles).
 //
 // We do care about the results of complex multiplication / division, since
 // these use code we've written.
 
+#include <stdio.h>
+
 // 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 <complex>).
+#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \
+    (__cplusplus < 201402L || STDLIB_VERSION >= 2014)
 
+#include <assert.h>
+#include <complex>
 #include <type_traits>
 
 template <class T>
@@ -69,7 +73,7 @@
 }
 
 __device__ void test_literals() {
-#if __cplusplus >= 201402L
+#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014
   using namespace std::literals::complex_literals;
 
   {
Index: test-suite/trunk/External/CUDA/CMakeLists.txt
===================================================================
--- test-suite/trunk/External/CUDA/CMakeLists.txt
+++ test-suite/trunk/External/CUDA/CMakeLists.txt
@@ -316,28 +316,33 @@
       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})
         set(_Stdlib_LDFLAGS  -stdlib=libstdc++)
         # 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()
 
       if(HAVE_LIBCXX)
-	# Same as above, but for libc++
-	# 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_LDFLAGS  -stdlib=libc++)
-	set(_Stdlib_Libs libcxx)
+        # Same as above, but for libc++
+        # 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 -DSTDLIB_VERSION=2017)
+        set(_Stdlib_LDFLAGS  -stdlib=libc++)
+        set(_Stdlib_Libs libcxx)
         create_cuda_test_variant(${_Std} "${_Cuda_Suffix}-${_Std_Suffix}-libc++")
       endif()
     endforeach()
Index: test-suite/trunk/External/CUDA/cmath.cu
===================================================================
--- test-suite/trunk/External/CUDA/cmath.cu
+++ test-suite/trunk/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<decltype(std::hypot((float)0, (float)0, (float)0)), float>::value), "");
     static_assert((std::is_same<decltype(std::hypot((float)0, (bool)0, (float)0)), double>::value), "");
     static_assert((std::is_same<decltype(std::hypot((float)0, (unsigned short)0, (double)0)), double>::value), "");
@@ -1158,8 +1158,8 @@
     static_assert((std::is_same<decltype(std::hypot((int)0, (int)0, (int)0)), double>::value), "");
     static_assert((std::is_same<decltype(hypot(Ambiguous(), Ambiguous(), Ambiguous())), Ambiguous>::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: test-suite/trunk/External/CUDA/algorithm.cu
===================================================================
--- test-suite/trunk/External/CUDA/algorithm.cu
+++ test-suite/trunk/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<int>()(1, 0));
   assert(std::min({5, 1, 10}) == 1);
   assert(std::max({5, 1, 10}, std::less<int>()) == 10);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to