endif(LLVM_ENABLE_MODULES)
endif( MSVC )
-if (MSVC AND NOT CLANG_CL)
- set(msvc_warning_flags
- # Disabled warnings.
- -wd4141 # Suppress ''modifier' : used more than once' (because of __forceinline combined with inline)
- -wd4146 # Suppress 'unary minus operator applied to unsigned type, result still unsigned'
- -wd4180 # Suppress 'qualifier applied to function type has no meaning; ignored'
- -wd4244 # Suppress ''argument' : conversion from 'type1' to 'type2', possible loss of data'
- -wd4258 # Suppress ''var' : definition from the for loop is ignored; the definition from the enclosing scope is used'
- -wd4267 # Suppress ''var' : conversion from 'size_t' to 'type', possible loss of data'
- -wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception'
- -wd4345 # Suppress 'behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized'
- -wd4351 # Suppress 'new behavior: elements of array 'array' will be default initialized'
- -wd4355 # Suppress ''this' : used in base member initializer list'
- -wd4456 # Suppress 'declaration of 'var' hides local variable'
- -wd4457 # Suppress 'declaration of 'var' hides function parameter'
- -wd4458 # Suppress 'declaration of 'var' hides class member'
- -wd4459 # Suppress 'declaration of 'var' hides global declaration'
- -wd4503 # Suppress ''identifier' : decorated name length exceeded, name was truncated'
- -wd4624 # Suppress ''derived class' : destructor could not be generated because a base class destructor is inaccessible'
- -wd4722 # Suppress 'function' : destructor never returns, potential memory leak
- -wd4800 # Suppress ''type' : forcing value to bool 'true' or 'false' (performance warning)'
- -wd4100 # Suppress 'unreferenced formal parameter'
- -wd4127 # Suppress 'conditional expression is constant'
- -wd4512 # Suppress 'assignment operator could not be generated'
- -wd4505 # Suppress 'unreferenced local function has been removed'
- -wd4610 # Suppress '<class> can never be instantiated'
- -wd4510 # Suppress 'default constructor could not be generated'
- -wd4702 # Suppress 'unreachable code'
- -wd4245 # Suppress 'signed/unsigned mismatch'
- -wd4706 # Suppress 'assignment within conditional expression'
- -wd4310 # Suppress 'cast truncates constant value'
- -wd4701 # Suppress 'potentially uninitialized local variable'
- -wd4703 # Suppress 'potentially uninitialized local pointer variable'
- -wd4389 # Suppress 'signed/unsigned mismatch'
- -wd4611 # Suppress 'interaction between '_setjmp' and C++ object destruction is non-portable'
- -wd4805 # Suppress 'unsafe mix of type <type> and type <type> in operation'
- -wd4204 # Suppress 'nonstandard extension used : non-constant aggregate initializer'
- -wd4577 # Suppress 'noexcept used with no exception handling mode specified; termination on exception is not guaranteed'
- -wd4091 # Suppress 'typedef: ignored on left of '' when no variable is declared'
- # C4592 is disabled because of false positives in Visual Studio 2015
- # Update 1. Re-evaluate the usefulness of this diagnostic with Update 2.
- -wd4592 # Suppress ''var': symbol will be dynamically initialized (implementation limitation)
- -wd4319 # Suppress ''operator' : zero extending 'type' to 'type' of greater size'
-
- # Ideally, we'd like this warning to be enabled, but MSVC 2013 doesn't
- # support the 'aligned' attribute in the way that clang sources requires (for
- # any code that uses the LLVM_ALIGNAS macro), so this is must be disabled to
- # avoid unwanted alignment warnings.
- # When we switch to requiring a version of MSVC that supports the 'alignas'
- # specifier (MSVC 2015?) this warning can be re-enabled.
- -wd4324 # Suppress 'structure was padded due to __declspec(align())'
-
- # Promoted warnings.
- -w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
-
- # Promoted warnings to errors.
- -we4238 # Promote 'nonstandard extension used : class rvalue used as lvalue' to error.
- )
+if (MSVC)
+ if (NOT CLANG_CL)
+ set(msvc_warning_flags
+ # Disabled warnings.
+ -wd4141 # Suppress ''modifier' : used more than once' (because of __forceinline combined with inline)
+ -wd4146 # Suppress 'unary minus operator applied to unsigned type, result still unsigned'
+ -wd4180 # Suppress 'qualifier applied to function type has no meaning; ignored'
+ -wd4244 # Suppress ''argument' : conversion from 'type1' to 'type2', possible loss of data'
+ -wd4258 # Suppress ''var' : definition from the for loop is ignored; the definition from the enclosing scope is used'
+ -wd4267 # Suppress ''var' : conversion from 'size_t' to 'type', possible loss of data'
+ -wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception'
+ -wd4345 # Suppress 'behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized'
+ -wd4351 # Suppress 'new behavior: elements of array 'array' will be default initialized'
+ -wd4355 # Suppress ''this' : used in base member initializer list'
+ -wd4456 # Suppress 'declaration of 'var' hides local variable'
+ -wd4457 # Suppress 'declaration of 'var' hides function parameter'
+ -wd4458 # Suppress 'declaration of 'var' hides class member'
+ -wd4459 # Suppress 'declaration of 'var' hides global declaration'
+ -wd4503 # Suppress ''identifier' : decorated name length exceeded, name was truncated'
+ -wd4624 # Suppress ''derived class' : destructor could not be generated because a base class destructor is inaccessible'
+ -wd4722 # Suppress 'function' : destructor never returns, potential memory leak
+ -wd4800 # Suppress ''type' : forcing value to bool 'true' or 'false' (performance warning)'
+ -wd4100 # Suppress 'unreferenced formal parameter'
+ -wd4127 # Suppress 'conditional expression is constant'
+ -wd4512 # Suppress 'assignment operator could not be generated'
+ -wd4505 # Suppress 'unreferenced local function has been removed'
+ -wd4610 # Suppress '<class> can never be instantiated'
+ -wd4510 # Suppress 'default constructor could not be generated'
+ -wd4702 # Suppress 'unreachable code'
+ -wd4245 # Suppress 'signed/unsigned mismatch'
+ -wd4706 # Suppress 'assignment within conditional expression'
+ -wd4310 # Suppress 'cast truncates constant value'
+ -wd4701 # Suppress 'potentially uninitialized local variable'
+ -wd4703 # Suppress 'potentially uninitialized local pointer variable'
+ -wd4389 # Suppress 'signed/unsigned mismatch'
+ -wd4611 # Suppress 'interaction between '_setjmp' and C++ object destruction is non-portable'
+ -wd4805 # Suppress 'unsafe mix of type <type> and type <type> in operation'
+ -wd4204 # Suppress 'nonstandard extension used : non-constant aggregate initializer'
+ -wd4577 # Suppress 'noexcept used with no exception handling mode specified; termination on exception is not guaranteed'
+ -wd4091 # Suppress 'typedef: ignored on left of '' when no variable is declared'
+ # C4592 is disabled because of false positives in Visual Studio 2015
+ # Update 1. Re-evaluate the usefulness of this diagnostic with Update 2.
+ -wd4592 # Suppress ''var': symbol will be dynamically initialized (implementation limitation)
+ -wd4319 # Suppress ''operator' : zero extending 'type' to 'type' of greater size'
+
+ # Ideally, we'd like this warning to be enabled, but MSVC 2013 doesn't
+ # support the 'aligned' attribute in the way that clang sources requires (for
+ # any code that uses the LLVM_ALIGNAS macro), so this is must be disabled to
+ # avoid unwanted alignment warnings.
+ # When we switch to requiring a version of MSVC that supports the 'alignas'
+ # specifier (MSVC 2015?) this warning can be re-enabled.
+ -wd4324 # Suppress 'structure was padded due to __declspec(align())'
+
+ # Promoted warnings.
+ -w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
+
+ # Promoted warnings to errors.
+ -we4238 # Promote 'nonstandard extension used : class rvalue used as lvalue' to error.
+ )
+ endif(NOT CLANG_CL)
# Enable warnings
if (LLVM_ENABLE_WARNINGS)
foreach(flag ${msvc_warning_flags})
append("${flag}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endforeach(flag)
-endif (MSVC AND NOT CLANG_CL)
+endif (MSVC)
if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
- append("-Wall -W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+
+ # Don't add -Wall for clang-cl, because it maps -Wall to -Weverything for
+ # MSVC compatibility. /W4 is added above instead.
+ if (NOT CLANG_CL)
+ append("-Wall" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ endif()
+
+ append("-W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
append("-Wcast-qual" CMAKE_CXX_FLAGS)
# Turn off missing field initializer warnings for gcc to avoid noise from