Skip to content

Commit

Permalink
Disable -Wmicrosoft-cast on clang-cl.
Browse files Browse the repository at this point in the history
There's no easy / clean way to make it not fire, so disabling globally.
It's also pretty harmless (on other systems we'd use reinterpret_cast),
so why bother.
  • Loading branch information
mosra committed Dec 18, 2019
1 parent 5183c9e commit 3b4cade
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions modules/UseCorrade.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_SIMULATE_ID STREQUAL "
"_CRT_SECURE_NO_WARNINGS" "_SCL_SECURE_NO_WARNINGS")
endif()

if(CORRADE_TARGET_CLANG_CL)
list(APPEND CORRADE_PEDANTIC_COMPILER_OPTIONS
# See Utility::Directory::libraryLocation() for details
"-Wno-microsoft-cast")
endif()

# Compiler flags to undo horrible crimes done by windows.h, common for both
# MSVC and MinGW
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC" OR MINGW)
Expand Down
13 changes: 10 additions & 3 deletions src/Corrade/Utility/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,21 @@ bool Debug::isTty(std::ostream* const output) {
ANSI colors enabled */
#elif defined(CORRADE_UTILITY_USE_ANSI_COLORS) || defined(CORRADE_TARGET_UNIX)
return
/* Windows RT projects have C4996 treated as error by default. WHY */
#ifdef _MSC_VER
/* Windows RT projects have C4996 treated as error by default. WHY.
Also, clang-cl doesn't understand warning IDs yet, so using its own
warning suppression right now. */
#ifdef CORRADE_TARGET_CLANG_CL
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(CORRADE_TARGET_MSVC)
#pragma warning(push)
#pragma warning(disable: 4996)
#endif
((output == &std::cout && isatty(1)) ||
(output == &std::cerr && isatty(2)))
#ifdef _MSC_VER
#ifdef CORRADE_TARGET_CLANG_CL
#pragma clang diagnostic pop
#elif defined(CORRADE_TARGET_MSVC)
#pragma warning(pop)
#endif
#ifdef CORRADE_TARGET_APPLE
Expand Down
5 changes: 5 additions & 0 deletions src/Corrade/Utility/Directory.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ struct FunctionPointer {
};

}
/* Unfortunately, on MSVC (and clang-cl), the const void* overload is picked
instead, as MSVC implements implicit cast from function pointers to void*
(while GCC doesn't). On clang-cl it prints a -Wmicrosoft-cast warning and there's no way to make it go to this overload first without using a
template, so the warning is disabled globally in UseCorrade.cmake. More
info here: https://bugs.chromium.org/p/chromium/issues/detail?id=550065 */
CORRADE_UTILITY_EXPORT std::string libraryLocation(Implementation::FunctionPointer address);
#endif
#endif
Expand Down

0 comments on commit 3b4cade

Please sign in to comment.