summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmUVHandlePtr.h8
-rw-r--r--Tests/CMakeLib/testUVHandlePtr.cxx16
2 files changed, 24 insertions, 0 deletions
diff --git a/Source/cmUVHandlePtr.h b/Source/cmUVHandlePtr.h
index 1b5eb9c..b8b3491 100644
--- a/Source/cmUVHandlePtr.h
+++ b/Source/cmUVHandlePtr.h
@@ -132,7 +132,15 @@ public:
uv_handle_ptr_base_(std::nullptr_t) {}
~uv_handle_ptr_base_() { this->reset(); }
+#if defined(__SUNPRO_CC)
+ // The Oracle Studio compiler recognizes 'explicit operator bool()' in
+ // 'if(foo)' but not 'if(foo && ...)'. The purpose of 'explicit' here
+ // is to avoid accidental conversion in non-boolean contexts. Just
+ // leave it out on this compiler so we can compile valid code.
+ operator bool() const;
+#else
explicit operator bool() const;
+#endif
/**
* Properly close the handle if needed and sets the inner handle to nullptr
diff --git a/Tests/CMakeLib/testUVHandlePtr.cxx b/Tests/CMakeLib/testUVHandlePtr.cxx
index c97d755..17f672d 100644
--- a/Tests/CMakeLib/testUVHandlePtr.cxx
+++ b/Tests/CMakeLib/testUVHandlePtr.cxx
@@ -7,6 +7,21 @@
#include "cmGetPipes.h"
#include "cmUVHandlePtr.h"
+static bool testBool()
+{
+ cm::uv_async_ptr async;
+ cm::uv_handle_ptr handle;
+ cm::uv_idle_ptr idle;
+ cm::uv_pipe_ptr pipe;
+ cm::uv_process_ptr process;
+ cm::uv_signal_ptr signal;
+ cm::uv_stream_ptr stream;
+ cm::uv_timer_ptr timer;
+ cm::uv_tty_ptr tty;
+ return !async && !handle && !idle && !pipe && !process && !signal &&
+ !stream && !timer && !tty;
+}
+
static bool testIdle()
{
bool idled = false;
@@ -130,6 +145,7 @@ static bool testWriteCallback()
int testUVHandlePtr(int, char** const)
{
bool passed = true;
+ passed = testBool() && passed;
passed = testIdle() && passed;
passed = testTimer() && passed;
passed = testWriteCallback() && passed;