aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2016-05-10 13:22:32 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2016-05-10 13:22:32 +0100
commit6f0800d418dd4d27936202543d3b4775527d204b (patch)
tree469f417b9f82882bb1ab87b339da51dd67397c26
parentf10b2e1cae04b545c9ea77a7b284ef45402d5b33 (diff)
downloadgcc-6f0800d418dd4d27936202543d3b4775527d204b.zip
gcc-6f0800d418dd4d27936202543d3b4775527d204b.tar.gz
gcc-6f0800d418dd4d27936202543d3b4775527d204b.tar.bz2
libstdc++/71037 Add base path to filesystem::canonical exceptions
PR libstdc++/71037 * src/filesystem/ops.cc (canonical(const path&, const path&)): Add base path to exception. * testsuite/experimental/filesystem/operations/canonical.cc: Test paths contained in exception. From-SVN: r236074
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/src/filesystem/ops.cc5
-rw-r--r--libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc20
3 files changed, 29 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 208b894..cf7ce6f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,11 @@
2016-05-10 Jonathan Wakely <jwakely@redhat.com>
+ PR libstdc++/71037
+ * src/filesystem/ops.cc (canonical(const path&, const path&)): Add
+ base path to exception.
+ * testsuite/experimental/filesystem/operations/canonical.cc: Test
+ paths contained in exception.
+
* testsuite/experimental/type_erased_allocator/2.cc: Remove unused
using declaration.
diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc
index aa26caf..e18c751 100644
--- a/libstdc++-v3/src/filesystem/ops.cc
+++ b/libstdc++-v3/src/filesystem/ops.cc
@@ -220,8 +220,9 @@ fs::canonical(const path& p, const path& base)
{
error_code ec;
path can = canonical(p, base, ec);
- if (ec.value())
- _GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot canonicalize", p, ec));
+ if (ec)
+ _GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot canonicalize", p, base,
+ ec));
return can;
}
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc
index e13c4bf..5b4c573 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc
@@ -59,8 +59,28 @@ test01()
VERIFY( !ec );
}
+void
+test02()
+{
+#if __cpp_exceptions
+ bool test __attribute__((unused)) = false;
+
+ fs::path p = "rel", base = __gnu_test::nonexistent_path();
+ fs::path e1, e2;
+ try {
+ canonical(p, base);
+ } catch (const fs::filesystem_error& e) {
+ e1 = e.path1();
+ e2 = e.path2();
+ }
+ VERIFY( e1 == p );
+ VERIFY( e2 == base );
+#endif
+}
+
int
main()
{
test01();
+ test02();
}