[libcxx] r292969 - Add a test to make sure that implicit conversion from error_code to bool will fail

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 24 11:44:55 PST 2017


Author: marshall
Date: Tue Jan 24 13:44:55 2017
New Revision: 292969

URL: http://llvm.org/viewvc/llvm-project?rev=292969&view=rev
Log:
Add a test to make sure that implicit conversion from error_code to bool will fail

Added:
    libcxx/trunk/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp

Added: libcxx/trunk/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp?rev=292969&view=auto
==============================================================================
--- libcxx/trunk/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp (added)
+++ libcxx/trunk/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp Tue Jan 24 13:44:55 2017
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// XFAIL: c++03
+
+// <system_error>
+
+// class error_code
+
+// explicit operator bool() const;
+
+#include <system_error>
+
+bool test_func(void)
+{
+    const std::error_code ec(0, std::generic_category());
+    return ec;   // conversion to bool is explicit; should fail.
+}
+
+int main()
+{
+    return 0;
+}
+




More information about the cfe-commits mailing list