Implement LWG2664 and update its status
authorEric Fiselier <eric@efcs.ca>
Sat, 15 Oct 2016 21:29:44 +0000 (21:29 +0000)
committerEric Fiselier <eric@efcs.ca>
Sat, 15 Oct 2016 21:29:44 +0000 (21:29 +0000)
llvm-svn: 284310

libcxx/include/experimental/filesystem
libcxx/test/libcxx/experimental/filesystem/class.path/path.member/path.append.pass.cpp [new file with mode: 0644]
libcxx/www/upcoming_meeting.html

index 10590a8..45de0d1 100644 (file)
@@ -759,6 +759,8 @@ private:
 public:
     // appends
     path& operator/=(const path& __p) {
+        _LIBCPP_ASSERT(!__p.has_root_name(),
+                      "cannot append to a path with a root name");
         __append_sep_if_needed(__p.empty() ? char{} : __p.__pn_[0]);
         __pn_ += __p.native();
         return *this;
diff --git a/libcxx/test/libcxx/experimental/filesystem/class.path/path.member/path.append.pass.cpp b/libcxx/test/libcxx/experimental/filesystem/class.path/path.member/path.append.pass.cpp
new file mode 100644 (file)
index 0000000..c43ea07
--- /dev/null
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <experimental/filesystem>
+
+// class path
+
+// path& operator/=(path const&)
+// path operator/(path const&, path const&)
+
+
+#define _LIBCPP_DEBUG 0
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)
+int AssertCount = 0;
+
+#include <experimental/filesystem>
+#include <type_traits>
+#include <string_view>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "count_new.hpp"
+#include "filesystem_test_helper.hpp"
+
+namespace fs = std::experimental::filesystem;
+
+int main()
+{
+  using namespace fs;
+  {
+    path lhs("//foo");
+    path rhs("/bar");
+    assert(AssertCount == 0);
+    lhs /= rhs;
+    assert(AssertCount == 0);
+  }
+  {
+    path lhs("//foo");
+    path rhs("/bar");
+    assert(AssertCount == 0);
+    (void)(lhs / rhs);
+    assert(AssertCount == 0);
+  }
+  {
+    path lhs("//foo");
+    path rhs("//bar");
+    assert(AssertCount == 0);
+    lhs /= rhs;
+    assert(AssertCount == 1);
+    AssertCount = 0;
+  }
+  {
+    path lhs("//foo");
+    path rhs("//bar");
+    assert(AssertCount == 0);
+    (void)(lhs / rhs);
+    assert(AssertCount == 1);
+  }
+  // FIXME The same error is not diagnosed for the append(Source) and
+  // append(It, It) overloads.
+}
index ffbc0a9..e0d53bd 100644 (file)
@@ -88,7 +88,7 @@
         <tr><td><a href="http://wg21.link/LWG2589">2589</a></td><td>match_results can't satisfy the requirements of a container</td><td>Issaquah</td><td>Nothing to do</td></tr>
         <tr><td><a href="http://wg21.link/LWG2591">2591</a></td><td>std::function's member template target() should not lead to undefined behaviour</td><td>Issaquah</td><td></td></tr>
         <tr><td><a href="http://wg21.link/LWG2598">2598</a></td><td>addressof works on temporaries</td><td>Issaquah</td><td>Patch ready</td></tr>
-        <tr><td><a href="http://wg21.link/LWG2664">2664</a></td><td>operator/ (and other append) semantics not useful if argument has root</td><td>Issaquah</td><td></td></tr>
+        <tr><td><a href="http://wg21.link/LWG2664">2664</a></td><td>operator/ (and other append) semantics not useful if argument has root</td><td>Issaquah</td><td>Nothing to do</td></tr>
         <tr><td><a href="http://wg21.link/LWG2665">2665</a></td><td>remove_filename() post condition is incorrect</td><td>Issaquah</td><td></td></tr>
         <tr><td><a href="http://wg21.link/LWG2672">2672</a></td><td>Should is_empty use error_code in its specification?</td><td>Issaquah</td><td></td></tr>
         <tr><td><a href="http://wg21.link/LWG2678">2678</a></td><td>std::filesystem enum classes overspecified</td><td>Issaquah</td><td>Nothing to do</td></tr>
 <li>2589 - This is just wording cleanup. </li>
 <li>2591 - I <b>suspect</b> that this is just better specification of the existing structure. Probably need more tests for this.</li>
 <li>2598 - Patch and tests ready</li>
-<li>2664 - File System; Eric?</li>
+<li>2664 - No change needed. _LIBCPP_DEBUG mode tests the new requirements.</li>
 <li>2665 - File System; Eric?</li>
 <li>2672 - File System; Eric?</li>
 <li>2678 - File System; Eric?</li>