Fix for -Wshadow warning, and some issues when compiling tests against std::filesystem on GCC 9.1

This commit is contained in:
Steffen Schuemann 2019-07-04 08:00:35 +02:00
parent 09bd182416
commit 8dee4d7731
4 changed files with 8 additions and 10 deletions

View File

@ -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()

View File

@ -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;

View File

@ -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
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Werror>
$<$<CXX_COMPILER_ID:GNU>:-Wall -Werror>
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Wshadow -Werror>
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Werror>
$<$<CXX_COMPILER_ID:MSVC>:/WX>)
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
target_compile_definitions(filesystem_test PRIVATE _CRT_SECURE_NO_WARNINGS)

View File

@ -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<TP::duration>(sctp - system_clock::now() + TP::clock::now());
auto tp = time_point_cast<typename TP::duration>(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<fs::file_time_type>(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]")