[PATCH] D46994: [test-suite] Test CUDA in C++14 mode with C++11 stdlibs.

2018-05-17 Thread Justin Lebar via Phabricator via cfe-commits
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=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 
-#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
 // 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 
+
 // 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;
 
   {
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::value), "");
 

[PATCH] D46994: [test-suite] Test CUDA in C++14 mode with C++11 stdlibs.

2018-05-17 Thread Justin Lebar via Phabricator via cfe-commits
jlebar marked an inline comment as done.
jlebar added a comment.

Thanks for the reviews, Art.  Submitting with this change...


Repository:
  rT test-suite

https://reviews.llvm.org/D46994



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46994: [test-suite] Test CUDA in C++14 mode with C++11 stdlibs.

2018-05-17 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: External/CUDA/CMakeLists.txt:339-345
# 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_CPPFLAGS -stdlib=libc++ 
-I${_compiler_path}/../include/c++-build -DSTDLIB_VERSION=2017)
set(_Stdlib_LDFLAGS  -stdlib=libc++)
set(_Stdlib_Libs libcxx)

Looks like the file should be un-tabified.


Repository:
  rT test-suite

https://reviews.llvm.org/D46994



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46994: [test-suite] Test CUDA in C++14 mode with C++11 stdlibs.

2018-05-16 Thread Justin Lebar via Phabricator via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
Herald added subscribers: llvm-commits, mgorny, sanjoy.

Previously (https://reviews.llvm.org/D46993) std::min/max didn't work in C++14 
mode with a C++11
stdlib; we'd assumed that compiler std=c++14 implied stdlib in C++14
mode.


Repository:
  rT test-suite

https://reviews.llvm.org/D46994

Files:
  External/CUDA/CMakeLists.txt
  External/CUDA/algorithm.cu
  External/CUDA/cmath.cu
  External/CUDA/complex.cu

Index: External/CUDA/complex.cu
===
--- External/CUDA/complex.cu
+++ External/CUDA/complex.cu
@@ -7,25 +7,29 @@
 //
 //===--===//
 
-#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
 // 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 
+
 // 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;
 
   {
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/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/CMakeLists.txt
===
--- External/CUDA/CMakeLists.txt
+++ External/CUDA/CMakeLists.txt
@@ -316,26 +316,31 @@
   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}