Author: ericwf
Date: Tue Oct 11 17:18:09 2016
New Revision: 283951

URL: http://llvm.org/viewvc/llvm-project?rev=283951&view=rev
Log:
Fix LWG2683 - filesystem::copy() should always clear the user-provided 
error_code

Modified:
    libcxx/trunk/src/experimental/filesystem/operations.cpp
    
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
    libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=283951&r1=283950&r2=283951&view=diff
==============================================================================
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Tue Oct 11 17:18:09 
2016
@@ -236,12 +236,8 @@ void __copy(const path& from, const path
         }
         return;
     }
-    else if (is_directory(f)) {
-        if (not bool(copy_options::recursive & options) &&
-            bool(copy_options::__in_recursive_copy & options))
-        {
-            return;
-        }
+    else if (is_directory(f) && (bool(copy_options::recursive & options) ||
+             copy_options::none == options)) {
 
         if (!exists(t)) {
             // create directory to with attributes from 'from'.

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp?rev=283951&r1=283950&r2=283951&view=diff
==============================================================================
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
 Tue Oct 11 17:18:09 2016
@@ -69,37 +69,44 @@ TEST_CASE(test_error_reporting)
     const path fifo = env.create_fifo("fifo");
     TEST_REQUIRE(is_other(fifo));
 
+    const auto test_ec = GetTestEC();
+
     // !exists(f)
     {
-        std::error_code ec;
+        std::error_code ec = test_ec;
         const path f = StaticEnv::DNE;
         const path t = env.test_root;
         fs::copy(f, t, ec);
         TEST_REQUIRE(ec);
+        TEST_REQUIRE(ec != test_ec);
         TEST_CHECK(checkThrow(f, t, ec));
     }
     { // equivalent(f, t) == true
-        std::error_code ec;
+        std::error_code ec = test_ec;
         fs::copy(file, file, ec);
         TEST_REQUIRE(ec);
+        TEST_REQUIRE(ec != test_ec);
         TEST_CHECK(checkThrow(file, file, ec));
     }
     { // is_directory(from) && is_file(to)
-        std::error_code ec;
+        std::error_code ec = test_ec;
         fs::copy(dir, file, ec);
         TEST_REQUIRE(ec);
+        TEST_REQUIRE(ec != test_ec);
         TEST_CHECK(checkThrow(dir, file, ec));
     }
     { // is_other(from)
-        std::error_code ec;
+        std::error_code ec = test_ec;
         fs::copy(fifo, dir, ec);
         TEST_REQUIRE(ec);
+        TEST_REQUIRE(ec != test_ec);
         TEST_CHECK(checkThrow(fifo, dir, ec));
     }
     { // is_other(to)
-        std::error_code ec;
+        std::error_code ec = test_ec;
         fs::copy(file, fifo, ec);
         TEST_REQUIRE(ec);
+        TEST_REQUIRE(ec != test_ec);
         TEST_CHECK(checkThrow(file, fifo, ec));
     }
 }
@@ -129,11 +136,13 @@ TEST_CASE(from_is_symlink)
         std::error_code ec = GetTestEC();
         fs::copy(symlink, file, copy_options::copy_symlinks, ec);
         TEST_CHECK(ec);
+        TEST_CHECK(ec != GetTestEC());
     }
     { // create symlinks but target exists
         std::error_code ec = GetTestEC();
         fs::copy(symlink, file, copy_options::create_symlinks, ec);
         TEST_CHECK(ec);
+        TEST_CHECK(ec != GetTestEC());
     }
 }
 
@@ -246,6 +255,19 @@ TEST_CASE(from_is_directory)
             TEST_CHECK(file_size(nested_created) == FI.size);
         }
     }
+}
 
+TEST_CASE(test_otherwise_no_effects_clause)
+{
+    scoped_test_env env;
+    const path dir = env.create_dir("dir1");
+    { // skip copy because of directory
+        const path dest = env.make_env_path("dest1");
+        std::error_code ec;
+        fs::copy(dir, dest, CO::directories_only, ec);
+        TEST_CHECK(!ec);
+        TEST_CHECK(!exists(dest));
+    }
 }
+
 TEST_SUITE_END()

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=283951&r1=283950&r2=283951&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue Oct 11 17:18:09 2016
@@ -286,7 +286,7 @@
        <tr><td><a href="http://wg21.link/LWG2671";>2671</a></td><td>Errors in 
Copy</td><td>Oulu</td><td>Complete</td></tr>
        <tr><td><a href="http://wg21.link/LWG2673";>2673</a></td><td>status() 
effects cannot be implemented as 
specified</td><td>Oulu</td><td>Complete</td></tr>
        <tr><td><a 
href="http://wg21.link/LWG2674";>2674</a></td><td>Bidirectional iterator 
requirement on path::iterator is very 
expensive</td><td>Oulu</td><td>Complete</td></tr>
-       <tr><td><a 
href="http://wg21.link/LWG2683";>2683</a></td><td>filesystem::copy() says "no 
effects"</td><td>Oulu</td><td></td></tr>
+       <tr><td><a 
href="http://wg21.link/LWG2683";>2683</a></td><td>filesystem::copy() says "no 
effects"</td><td>Oulu</td><td>Complete</td></tr>
        <tr><td><a 
href="http://wg21.link/LWG2684";>2684</a></td><td>priority_queue lacking 
comparator typedef</td><td>Oulu</td><td>Complete</td></tr>
        <tr><td><a href="http://wg21.link/LWG2685";>2685</a></td><td>shared_ptr 
deleters must not throw on move 
construction</td><td>Oulu</td><td>Complete</td></tr>
        <tr><td><a 
href="http://wg21.link/LWG2687";>2687</a></td><td>{inclusive,exclusive}_scan 
misspecified</td><td>Oulu</td><td></td></tr>


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to