diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -577,7 +577,7 @@ # -Wall is equivalent to -Weverything in GCC style compiler drivers.) target_add_compile_flags_if_supported(${target} PRIVATE -W4) else() - target_add_compile_flags_if_supported(${target} PRIVATE -Wall) + target_add_compile_flags_if_supported(${target} PRIVATE -Wall -Wundef) endif() target_add_compile_flags_if_supported(${target} PRIVATE -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -348,7 +348,7 @@ # define _LIBCPP_NO_CFI #endif -#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L +#if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L # if defined(__FreeBSD__) # define _LIBCPP_HAS_ALIGNED_ALLOC # define _LIBCPP_HAS_QUICK_EXIT diff --git a/libcxx/include/ext/hash_map b/libcxx/include/ext/hash_map --- a/libcxx/include/ext/hash_map +++ b/libcxx/include/ext/hash_map @@ -208,7 +208,7 @@ #include #include -#if __DEPRECATED +#if defined(__DEPRECATED) && __DEPRECATED #if defined(_LIBCPP_WARNING) _LIBCPP_WARNING("Use of the header is deprecated. Migrate to ") #else diff --git a/libcxx/include/ext/hash_set b/libcxx/include/ext/hash_set --- a/libcxx/include/ext/hash_set +++ b/libcxx/include/ext/hash_set @@ -197,7 +197,7 @@ #include #include -#if __DEPRECATED +#if defined(__DEPRECATED) && __DEPRECATED #if defined(_LIBCPP_WARNING) _LIBCPP_WARNING("Use of the header is deprecated. Migrate to ") #else diff --git a/libcxx/include/future b/libcxx/include/future --- a/libcxx/include/future +++ b/libcxx/include/future @@ -501,8 +501,8 @@ error_code __ec_; public: future_error(error_code __ec); -#if _LIBCPP_STD_VERS > 14 - explicit future_error(future_errc _Ev) : logic_error(), __ec_(make_error_code(_Ev)) {} +#if _LIBCPP_STD_VER > 14 + // explicit future_error(future_errc _Ev) : logic_error(), __ec_(make_error_code(_Ev)) {} #endif _LIBCPP_INLINE_VISIBILITY const error_code& code() const _NOEXCEPT {return __ec_;} diff --git a/libcxx/test/std/atomics/types.pass.cpp b/libcxx/test/std/atomics/types.pass.cpp --- a/libcxx/test/std/atomics/types.pass.cpp +++ b/libcxx/test/std/atomics/types.pass.cpp @@ -24,12 +24,13 @@ #include #include + +#include "test_macros.h" + #if TEST_STD_VER >= 20 # include #endif -#include "test_macros.h" - template struct test_atomic { diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq_all_zero.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq_all_zero.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq_all_zero.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq_all_zero.pass.cpp @@ -25,10 +25,11 @@ #include #include #include -#if TEST_STD_VER >= 11 -#include #include "test_macros.h" + +#if TEST_STD_VER >= 11 +#include #endif struct all_zero_seed_seq { diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp @@ -19,11 +19,11 @@ #include #include +#include "test_macros.h" + #if TEST_STD_VER >= 11 #include "poisoned_hash_helper.h" -#include "test_macros.h" - struct A {}; #endif diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -165,7 +165,8 @@ // Sniff out to see if the underlying C library has C11 features // This is cribbed from __config; but lives here as well because we can't assume libc++ -#if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11 +#if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || \ + TEST_STD_VER >= 11 # if defined(__FreeBSD__) # if __FreeBSD_version >= 1300064 || \ (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000) diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py --- a/libcxx/utils/libcxx/test/params.py +++ b/libcxx/utils/libcxx/test/params.py @@ -14,6 +14,7 @@ '-Wall', '-Wextra', '-Wshadow', + '-Wundef', '-Wno-unused-command-line-argument', '-Wno-attributes', '-Wno-pessimizing-move',