Make Wunused-local-typedef a hard error (#77918)

Only allow it for `libtorch_python` and tests
Helps prevent regression like https://github.com/pytorch/pytorch/pull/76547#issuecomment-1132208232

Pull Request resolved: https://github.com/pytorch/pytorch/pull/77918
Approved by: https://github.com/osalpekar, https://github.com/seemethere
This commit is contained in:
Nikita Shulga 2022-06-09 18:14:01 +00:00 committed by PyTorch MergeBot
parent db08eb88e6
commit 3255ddeec9
3 changed files with 3 additions and 1 deletions

View File

@ -791,7 +791,6 @@ if(NOT MSVC)
string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-parameter")
string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-function")
string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-result")
string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-local-typedefs")
string(APPEND CMAKE_CXX_FLAGS " -Wno-strict-overflow")
string(APPEND CMAKE_CXX_FLAGS " -Wno-strict-aliasing")
string(APPEND CMAKE_CXX_FLAGS " -Wno-error=deprecated-declarations")

View File

@ -55,6 +55,7 @@ target_include_directories(test_api PRIVATE ${ATen_CPU_INCLUDE})
target_link_libraries(test_api PRIVATE torch gtest)
if(NOT MSVC)
target_compile_options(test_api PRIVATE -Wno-unused-variable)
target_compile_options(test_api PRIVATE -Wno-unused-local-typedefs)
endif()
if(USE_CUDA)

View File

@ -268,6 +268,7 @@ if(USE_DEPLOY)
add_library(torch_python_obj OBJECT ${TORCH_PYTHON_SRCS})
if(NOT MSVC)
target_compile_options(torch_python_obj PRIVATE -Wno-unused-variable)
target_compile_options(torch_python_obj PRIVATE -Wno-unused-local-typedefs)
endif()
if(USE_DISTRIBUTED)
# Set c10d-related compile definitions. For a "normal" build of
@ -379,6 +380,7 @@ endif()
if(NOT MSVC)
target_compile_options(torch_python PRIVATE -Wno-unused-variable)
target_compile_options(torch_python PRIVATE -Wno-unused-local-typedefs)
endif()
# Required workaround for generated sources