summaryrefslogtreecommitdiff
path: root/test/std
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-10-30 18:59:59 +0000
committerEric Fiselier <eric@efcs.ca>2017-10-30 18:59:59 +0000
commita4c272d82f58593ba96babf7bca7e3be7c993a03 (patch)
tree9260475b3739c5a6b8302818e86b68396ba8d241 /test/std
parentfba9cd8c9e50509aceaef0944899cbf89b395b64 (diff)
Implement LWG 3013 - some filesystem members should not be noexcept.
LWG 3013 points out that the constructors and increment members of the directory iterators need to allocate, and therefore cannot be marked noexcept. It also points out that `is_empty` and `copy` likely need to allocate as well, and as such can also not be noexcept. This patch speculatively implements the resolution removing noexcept, because libc++ does indeed have the possibility of throwing on allocation failure. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@316941 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/std')
-rw-r--r--test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp19
-rw-r--r--test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/increment.pass.cpp4
-rw-r--r--test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp16
-rw-r--r--test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp2
-rw-r--r--test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp8
-rw-r--r--test/std/experimental/filesystem/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp4
6 files changed, 32 insertions, 21 deletions
diff --git a/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp b/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
index 830e81231..4fd60887b 100644
--- a/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
+++ b/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
@@ -15,8 +15,8 @@
// explicit directory_iterator(const path& p);
// directory_iterator(const path& p, directory_options options);
-// directory_iterator(const path& p, error_code& ec) noexcept;
-// directory_iterator(const path& p, directory_options options, error_code& ec) noexcept;
+// directory_iterator(const path& p, error_code& ec);
+// directory_iterator(const path& p, directory_options options, error_code& ec);
#include <experimental/filesystem>
#include <type_traits>
@@ -40,15 +40,22 @@ TEST_CASE(test_constructor_signatures)
static_assert(std::is_constructible<D, path>::value, "");
static_assert(!std::is_nothrow_constructible<D, path>::value, "");
- // directory_iterator(path const&, error_code&) noexcept
- static_assert(std::is_nothrow_constructible<D, path, std::error_code&>::value, "");
+ // directory_iterator(path const&, error_code&)
+ static_assert(std::is_constructible<D, path,
+ std::error_code&>::value, "");
+ static_assert(!std::is_nothrow_constructible<D, path,
+ std::error_code&>::value, "");
// directory_iterator(path const&, directory_options);
static_assert(std::is_constructible<D, path, directory_options>::value, "");
static_assert(!std::is_nothrow_constructible<D, path, directory_options>::value, "");
- // directory_iterator(path const&, directory_options, error_code&) noexcept
- static_assert(std::is_nothrow_constructible<D, path, directory_options, std::error_code&>::value, "");
+ // directory_iterator(path const&, directory_options, error_code&)
+ static_assert(std::is_constructible<D, path, directory_options,
+ std::error_code&>::value, "");
+ static_assert(!std::is_nothrow_constructible<D, path, directory_options,
+ std::error_code&>::value, "");
+
}
TEST_CASE(test_construction_from_bad_path)
diff --git a/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/increment.pass.cpp b/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/increment.pass.cpp
index 589b4eca7..8d888717b 100644
--- a/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/increment.pass.cpp
+++ b/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/increment.pass.cpp
@@ -14,7 +14,7 @@
// class directory_iterator
// directory_iterator& operator++();
-// directory_iterator& increment(error_code& ec) noexcept;
+// directory_iterator& increment(error_code& ec);
#include <experimental/filesystem>
#include <type_traits>
@@ -40,7 +40,7 @@ TEST_CASE(test_increment_signatures)
ASSERT_NOT_NOEXCEPT(++d);
ASSERT_SAME_TYPE(decltype(d.increment(ec)), directory_iterator&);
- ASSERT_NOEXCEPT(d.increment(ec));
+ ASSERT_NOT_NOEXCEPT(d.increment(ec));
}
TEST_CASE(test_prefix_increment)
diff --git a/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp b/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
index 8f6009d39..1469dae04 100644
--- a/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
+++ b/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
@@ -16,8 +16,8 @@
//
// explicit recursive_directory_iterator(const path& p);
// recursive_directory_iterator(const path& p, directory_options options);
-// recursive_directory_iterator(const path& p, error_code& ec) noexcept;
-// recursive_directory_iterator(const path& p, directory_options options, error_code& ec) noexcept;
+// recursive_directory_iterator(const path& p, error_code& ec);
+// recursive_directory_iterator(const path& p, directory_options options, error_code& ec);
#include <experimental/filesystem>
@@ -44,15 +44,19 @@ TEST_CASE(test_constructor_signatures)
static_assert(std::is_constructible<D, path>::value, "");
static_assert(!std::is_nothrow_constructible<D, path>::value, "");
- // directory_iterator(path const&, error_code&) noexcept
- static_assert(std::is_nothrow_constructible<D, path, std::error_code&>::value, "");
+ // directory_iterator(path const&, error_code&)
+ static_assert(std::is_constructible<D, path,
+ std::error_code&>::value, "");
+ static_assert(!std::is_nothrow_constructible<D, path,
+ std::error_code&>::value, "");
// directory_iterator(path const&, directory_options);
static_assert(std::is_constructible<D, path, directory_options>::value, "");
static_assert(!std::is_nothrow_constructible<D, path, directory_options>::value, "");
- // directory_iterator(path const&, directory_options, error_code&) noexcept
- static_assert(std::is_nothrow_constructible<D, path, directory_options, std::error_code&>::value, "");
+ // directory_iterator(path const&, directory_options, error_code&)
+ static_assert(std::is_constructible<D, path, directory_options, std::error_code&>::value, "");
+ static_assert(!std::is_nothrow_constructible<D, path, directory_options, std::error_code&>::value, "");
}
TEST_CASE(test_construction_from_bad_path)
diff --git a/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp b/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
index e91bd50f2..ea81ee253 100644
--- a/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
+++ b/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
@@ -40,7 +40,7 @@ TEST_CASE(test_increment_signatures)
ASSERT_NOT_NOEXCEPT(++d);
ASSERT_SAME_TYPE(decltype(d.increment(ec)), recursive_directory_iterator&);
- ASSERT_NOEXCEPT(d.increment(ec));
+ ASSERT_NOT_NOEXCEPT(d.increment(ec));
}
TEST_CASE(test_prefix_increment)
diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
index c9b42b359..8f44e0d5a 100644
--- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
+++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
@@ -12,10 +12,10 @@
// <experimental/filesystem>
// void copy(const path& from, const path& to);
-// void copy(const path& from, const path& to, error_code& ec) noexcept;
+// void copy(const path& from, const path& to, error_code& ec);
// void copy(const path& from, const path& to, copy_options options);
// void copy(const path& from, const path& to, copy_options options,
-// error_code& ec) noexcept;
+// error_code& ec);
#include <experimental/filesystem>
#include <type_traits>
@@ -39,9 +39,9 @@ TEST_CASE(signature_test)
std::error_code ec; ((void)ec);
const copy_options opts{}; ((void)opts);
ASSERT_NOT_NOEXCEPT(fs::copy(p, p));
- ASSERT_NOEXCEPT(fs::copy(p, p, ec));
+ ASSERT_NOT_NOEXCEPT(fs::copy(p, p, ec));
ASSERT_NOT_NOEXCEPT(copy(p, p, opts));
- ASSERT_NOEXCEPT(copy(p, p, opts, ec));
+ ASSERT_NOT_NOEXCEPT(copy(p, p, opts, ec));
}
// There are 4 cases is the proposal for absolute path.
diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
index bc62086c2..2da163c33 100644
--- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
+++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
@@ -12,7 +12,7 @@
// <experimental/filesystem>
// bool is_empty(path const& p);
-// bool is_empty(path const& p, std::error_code& ec) noexcept;
+// bool is_empty(path const& p, std::error_code& ec);
#include <experimental/filesystem>
#include <type_traits>
@@ -30,7 +30,7 @@ TEST_CASE(signature_test)
{
const path p; ((void)p);
std::error_code ec; ((void)ec);
- ASSERT_NOEXCEPT(is_empty(p, ec));
+ ASSERT_NOT_NOEXCEPT(is_empty(p, ec));
ASSERT_NOT_NOEXCEPT(is_empty(p));
}