From 8dee4d77316a2997783e859293b790fb97fb2123 Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Thu, 4 Jul 2019 08:00:35 +0200 Subject: [PATCH] Fix for -Wshadow warning, and some issues when compiling tests against std::filesystem on GCC 9.1 --- cmake/GhcHelper.cmake | 4 +++- include/ghc/filesystem.hpp | 4 ++-- test/CMakeLists.txt | 4 ++-- test/filesystem_test.cpp | 6 +----- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cmake/GhcHelper.cmake b/cmake/GhcHelper.cmake index b095d2e..4ebbe73 100644 --- a/cmake/GhcHelper.cmake +++ b/cmake/GhcHelper.cmake @@ -21,7 +21,9 @@ endif() if (CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 8.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)) add_executable(${targetName} ${ARGN}) set_property(TARGET ${targetName} PROPERTY CXX_STANDARD 17) - target_link_libraries(${targetName} -lstdc++fs) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + target_link_libraries(${targetName} -lstdc++fs) + endif() target_compile_definitions(${targetName} PRIVATE USE_STD_FS) endif() diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index ae3a63a..d0e019b 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -705,9 +705,9 @@ public: // other members as required by 27.2.3, input iterators proxy operator++(int) { - proxy proxy{**this}; + proxy p{**this}; ++*this; - return proxy; + return p; } bool operator==(const directory_iterator& rhs) const; bool operator!=(const directory_iterator& rhs) const; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3a553bf..21c6d05 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,8 +18,8 @@ else() add_executable(filesystem_test filesystem_test.cpp catch.hpp) target_link_libraries(filesystem_test ghc_filesystem) target_compile_options(filesystem_test PRIVATE - $<$:-Wall -Wextra -Werror> - $<$:-Wall -Werror> + $<$:-Wall -Wextra -Wshadow -Werror> + $<$:-Wall -Wextra -Wshadow -Werror> $<$:/WX>) if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) target_compile_definitions(filesystem_test PRIVATE _CRT_SECURE_NO_WARNINGS) diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index 9c8d4ec..1c6a1c6 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -116,7 +116,7 @@ TP from_time_t(std::time_t t) { using namespace std::chrono; auto sctp = system_clock::from_time_t(t); - auto tp = time_point_cast(sctp - system_clock::now() + TP::clock::now()); + auto tp = time_point_cast(sctp - system_clock::now() + TP::clock::now()); return tp; } @@ -2261,11 +2261,7 @@ static fs::file_time_type timeFromString(const std::string& str) if (is.fail()) { throw std::exception(); } -#ifdef IS_WCHAR_PATH return from_time_t(std::mktime(&tm)); -#else - return fs::file_time_type::clock::from_time_t(std::mktime(&tm)); -#endif } TEST_CASE("30.10.15.25 last_write_time", "[filesystem][operations][fs.op.last_write_time]")