From bbcfec7edd010aeb2f86780b7491a400dbe0f5d9 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 15 Oct 2016 21:29:44 +0000 Subject: [PATCH] Implement LWG2664 and update its status llvm-svn: 284310 --- libcxx/include/experimental/filesystem | 2 + .../path.member/path.append.pass.cpp | 70 +++++++++++++++++++ libcxx/www/upcoming_meeting.html | 4 +- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 libcxx/test/libcxx/experimental/filesystem/class.path/path.member/path.append.pass.cpp diff --git a/libcxx/include/experimental/filesystem b/libcxx/include/experimental/filesystem index 10590a8c0672..45de0d19cb5d 100644 --- a/libcxx/include/experimental/filesystem +++ b/libcxx/include/experimental/filesystem @@ -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 index 000000000000..c43ea078f989 --- /dev/null +++ b/libcxx/test/libcxx/experimental/filesystem/class.path/path.member/path.append.pass.cpp @@ -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 + +// + +// 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 +#include +#include +#include + +#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. +} diff --git a/libcxx/www/upcoming_meeting.html b/libcxx/www/upcoming_meeting.html index ffbc0a92e676..e0d53bdb0539 100644 --- a/libcxx/www/upcoming_meeting.html +++ b/libcxx/www/upcoming_meeting.html @@ -88,7 +88,7 @@ 2589match_results can't satisfy the requirements of a containerIssaquahNothing to do 2591std::function's member template target() should not lead to undefined behaviourIssaquah 2598addressof works on temporariesIssaquahPatch ready - 2664operator/ (and other append) semantics not useful if argument has rootIssaquah + 2664operator/ (and other append) semantics not useful if argument has rootIssaquahNothing to do 2665remove_filename() post condition is incorrectIssaquah 2672Should is_empty use error_code in its specification?Issaquah 2678std::filesystem enum classes overspecifiedIssaquahNothing to do @@ -166,7 +166,7 @@
  • 2589 - This is just wording cleanup.
  • 2591 - I suspect that this is just better specification of the existing structure. Probably need more tests for this.
  • 2598 - Patch and tests ready
  • -
  • 2664 - File System; Eric?
  • +
  • 2664 - No change needed. _LIBCPP_DEBUG mode tests the new requirements.
  • 2665 - File System; Eric?
  • 2672 - File System; Eric?
  • 2678 - File System; Eric?