rogfer01 created this revision.
rogfer01 added reviewers: EricWF, mclow.lists, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Under libcpp-no-exceptions, noexcept is trivially true. Some tests expect in 
the usual setting to return false. Wrap these tests in a convenience macro.


https://reviews.llvm.org/D27310

Files:
  test/libcxx/strings/iterators.exceptions.pass.cpp


Index: test/libcxx/strings/iterators.exceptions.pass.cpp
===================================================================
--- test/libcxx/strings/iterators.exceptions.pass.cpp
+++ test/libcxx/strings/iterators.exceptions.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===----------------------------------------------------------------------===//
 //
-// XFAIL: libcpp-no-exceptions
 // <iterator>
 
 // __libcpp_is_trivial_iterator<Tp>
@@ -26,6 +25,17 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
+// Wrapper for tests that expect a false noexcept. Usually a no-op but
+// see comment after #else.
+#define TEST_FOR_FALSE(x) (x)
+#else
+// Under libcpp-no-exceptions all noexcept expressions are trivially true, so
+// any check for a noexcept returning false must actually check for it being
+// true, so we negate the result.
+#define TEST_FOR_FALSE(x) (!(x))
+#endif
+
 int main()
 {
 //  basic tests
@@ -43,17 +53,17 @@
     static_assert(( 
std::__libcpp_string_gets_noexcept_iterator<std::reverse_iterator<std::__wrap_iter<char
 *> > > ::value), "");
 
 //  iterators in the libc++ test suite
-    
static_assert((!std::__libcpp_string_gets_noexcept_iterator<output_iterator     
  <char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<input_iterator 
       <char *> >::value), "");
-    
static_assert((!std::__libcpp_string_gets_noexcept_iterator<forward_iterator    
  <char *> >::value), "");
-    
static_assert((!std::__libcpp_string_gets_noexcept_iterator<bidirectional_iterator<char
 *> >::value), "");
-    
static_assert((!std::__libcpp_string_gets_noexcept_iterator<random_access_iterator<char
 *> >::value), "");
-    
static_assert((!std::__libcpp_string_gets_noexcept_iterator<ThrowingIterator    
  <char *> >::value), "");
+    
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<output_iterator
       <char *> >::value), "");
+    
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<input_iterator
        <char *> >::value), "");
+    
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<forward_iterator
      <char *> >::value), "");
+    
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<bidirectional_iterator<char
 *> >::value), "");
+    
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<random_access_iterator<char
 *> >::value), "");
+    
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<ThrowingIterator
      <char *> >::value), "");
 
 #if TEST_STD_VER >= 11
     static_assert(( 
std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator   <char *> 
>::value), "");
 #else
-    
static_assert((!std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator 
  <char *> >::value), "");
+    
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator
   <char *> >::value), "");
 #endif
 
 //


Index: test/libcxx/strings/iterators.exceptions.pass.cpp
===================================================================
--- test/libcxx/strings/iterators.exceptions.pass.cpp
+++ test/libcxx/strings/iterators.exceptions.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// XFAIL: libcpp-no-exceptions
 // <iterator>
 
 // __libcpp_is_trivial_iterator<Tp>
@@ -26,6 +25,17 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
+// Wrapper for tests that expect a false noexcept. Usually a no-op but
+// see comment after #else.
+#define TEST_FOR_FALSE(x) (x)
+#else
+// Under libcpp-no-exceptions all noexcept expressions are trivially true, so
+// any check for a noexcept returning false must actually check for it being
+// true, so we negate the result.
+#define TEST_FOR_FALSE(x) (!(x))
+#endif
+
 int main()
 {
 //  basic tests
@@ -43,17 +53,17 @@
     static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::reverse_iterator<std::__wrap_iter<char *> > > ::value), "");
 
 //  iterators in the libc++ test suite
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<output_iterator       <char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<input_iterator        <char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<forward_iterator      <char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<bidirectional_iterator<char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<random_access_iterator<char *> >::value), "");
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<ThrowingIterator      <char *> >::value), "");
+    static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<output_iterator       <char *> >::value), "");
+    static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<input_iterator        <char *> >::value), "");
+    static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<forward_iterator      <char *> >::value), "");
+    static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<bidirectional_iterator<char *> >::value), "");
+    static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<random_access_iterator<char *> >::value), "");
+    static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<ThrowingIterator      <char *> >::value), "");
 
 #if TEST_STD_VER >= 11
     static_assert(( std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator   <char *> >::value), "");
 #else
-    static_assert((!std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator   <char *> >::value), "");
+    static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator   <char *> >::value), "");
 #endif
 
 //
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D27310: Handle... Roger Ferrer Ibanez via Phabricator via cfe-commits

Reply via email to