Fix catch_reference_nullptr.pass.cpp test for GCC.
authorEric Fiselier <eric@efcs.ca>
Fri, 20 Jan 2017 19:34:19 +0000 (19:34 +0000)
committerEric Fiselier <eric@efcs.ca>
Fri, 20 Jan 2017 19:34:19 +0000 (19:34 +0000)
This test contained an implicit conversion from nullptr to bool.
Clang warns about this but the test had supressed that warning.
However GCC diagnoses the same code as an error and requires
-fpermissive to accept it.

This patch fixes both the warning and the error by explicitly
converting the pointer to bool.

llvm-svn: 292638

libcxxabi/test/catch_reference_nullptr.pass.cpp

index 3ab520f..82a49df 100644 (file)
 #include <cassert>
 #include <cstdlib>
 
-// Clang emits a warning on converting an object of type nullptr_t to bool,
-// even in generic code. Suppress it.
-#if defined(__clang__)
-#pragma clang diagnostic ignored "-Wnull-conversion"
-#endif
-
 struct A {};
 
 template<typename T, bool CanCatchNullptr>
@@ -25,7 +19,7 @@ static void catch_nullptr_test() {
   try {
     throw nullptr;
   } catch (T &p) {
-    assert(CanCatchNullptr && !p);
+    assert(CanCatchNullptr && !static_cast<bool>(p));
   } catch (...) {
     assert(!CanCatchNullptr);
   }