[libc++] Add warning pragma macros in the test suite

Reviewed By: ldionne, #libc, EricWF

Spies: EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D121552
This commit is contained in:
Nikolas Klauser 2022-03-14 14:30:24 +01:00
parent fb99266401
commit 14324fa428
42 changed files with 129 additions and 252 deletions

View File

@ -25,16 +25,14 @@
# define WIN32_LEAN_AND_MEAN
# define NOMINMAX
# include <windows.h>
#endif
#if !defined(_LIBCPP_WIN32API)
#else
# include <dirent.h> // for DIR & friends
# include <fcntl.h> /* values for fchmodat */
# include <sys/stat.h>
# include <sys/statvfs.h>
# include <sys/time.h> // for ::utimes as used in __last_write_time
# include <unistd.h>
#endif
#endif // defined(_LIBCPP_WIN32API)
#include "../include/apple_availability.h"
@ -46,10 +44,9 @@
#endif
#endif
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
_LIBCPP_DIAGNOSTIC_PUSH
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wunused-function")
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-function")
#if defined(_LIBCPP_WIN32API)
#define PS(x) (L##x)
@ -611,4 +608,6 @@ static file_time_type get_write_time(const WIN32_FIND_DATAW& data) {
_LIBCPP_END_NAMESPACE_FILESYSTEM
_LIBCPP_DIAGNOSTIC_POP
#endif // FILESYSTEM_COMMON_H

View File

@ -6,17 +6,11 @@
//
//===----------------------------------------------------------------------===//
#if defined(__clang__)
#pragma clang diagnostic ignored "-W#warnings"
#endif
#define min THIS IS A NASTY MACRO!
#define max THIS IS A NASTY MACRO!
#include <map>
#include "test_macros.h"
int main(int, char**) {
std::map<int, int> m;
((void)m);

View File

@ -20,10 +20,6 @@
// 1. noexcept and constexpr
// 2. Two closing '>' without a space.
#ifdef __clang__
#pragma clang diagnostic ignored "-Wc++11-extensions"
#endif
#include <type_traits>
#include <cassert>

View File

@ -5,15 +5,9 @@
//
//===----------------------------------------------------------------------===//
#if defined(__clang__)
#pragma clang diagnostic ignored "-W#warnings"
#endif
#define min THIS IS A NASTY MACRO!
#define max THIS IS A NASTY MACRO!
#include <cmath>
#include "test_macros.h"
int main(int, char**) { return 0; }

View File

@ -12,12 +12,9 @@
// See llvm.org/PR20855
#ifdef __clang__
#pragma clang diagnostic ignored "-Wdangling-field"
#endif
#include <tuple>
#include <string>
#include "test_macros.h"
template <class Tp>

View File

@ -22,13 +22,6 @@
#include "archetypes.h"
#include "test_macros.h"
// Clang warns about missing braces when initializing std::array.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wmissing-braces"
#endif
int main(int, char**)
{
using C = TestTypes::TestType;

View File

@ -14,18 +14,15 @@
// constexpr void // constexpr after c++17
// generate_n(Iter first, Size n, Generator gen);
#include "test_macros.h"
#ifdef TEST_COMPILER_MSVC
#pragma warning(disable: 4244) // conversion from 'const double' to 'int', possible loss of data
#endif
#include <algorithm>
#include <cassert>
#include "test_iterators.h"
#include "test_macros.h"
#include "user_defined_integral.h"
TEST_MSVC_DIAGNOSTIC_IGNORED(4244) // conversion from 'const double' to 'int', possible loss of data
struct gen_test
{
TEST_CONSTEXPR int operator()() const {return 2;}

View File

@ -11,13 +11,13 @@
// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
// Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Warray-bounds"
#endif
// ADDITIONAL_COMPILE_FLAGS: -Wno-array-bounds
#include <array>
#include <cassert>
#include "test_macros.h"
int main(int, char**)
{
{

View File

@ -10,11 +10,6 @@
// tuple_element<I, array<T, N> >::type
// Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Warray-bounds"
#endif
#include <array>
#include <cassert>

View File

@ -165,14 +165,10 @@ void test_ctor_with_different_value_type() {
// Make sure initialization is performed with each element value, not with
// a memory blob.
float array[3] = {0.0f, 1.0f, 2.0f};
#ifdef TEST_COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable: 4244) // conversion from 'float' to 'int', possible loss of data
#endif // TEST_COMPILER_MSVC
TEST_DIAGNOSTIC_PUSH
TEST_MSVC_DIAGNOSTIC_IGNORED(4244) // conversion from 'float' to 'int', possible loss of data
std::vector<int> v(array, array + 3);
#ifdef TEST_COMPILER_MSVC
#pragma warning(pop)
#endif // TEST_COMPILER_MSVC
TEST_DIAGNOSTIC_POP
assert(v[0] == 0);
assert(v[1] == 1);
assert(v[2] == 2);

View File

@ -108,10 +108,9 @@ struct has_abs : decltype(has_abs_imp<T>(0)) {};
void test_abs()
{
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wabsolute-value"
#endif
TEST_DIAGNOSTIC_PUSH
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wabsolute-value")
static_assert((std::is_same<decltype(abs((float)0)), float>::value), "");
static_assert((std::is_same<decltype(abs((double)0)), double>::value), "");
static_assert(
@ -132,9 +131,7 @@ void test_abs()
static_assert(!has_abs<unsigned long>::value, "");
static_assert(!has_abs<unsigned long long>::value, "");
#ifdef __clang__
#pragma clang diagnostic pop
#endif
TEST_DIAGNOSTIC_POP
assert(abs(-1.) == 1);
}

View File

@ -98,10 +98,8 @@
#include <cstdarg>
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // for tmpnam
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wformat-zero-length")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wformat-zero-length")
int main(int, char**)
{
@ -120,7 +118,11 @@ int main(int, char**)
static_assert((std::is_same<decltype(remove("")), int>::value), "");
static_assert((std::is_same<decltype(rename("","")), int>::value), "");
static_assert((std::is_same<decltype(tmpfile()), FILE*>::value), "");
TEST_DIAGNOSTIC_PUSH
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
static_assert((std::is_same<decltype(tmpnam(cp)), char*>::value), "");
TEST_DIAGNOSTIC_POP
static_assert((std::is_same<decltype(fclose(fp)), int>::value), "");
static_assert((std::is_same<decltype(fflush(fp)), int>::value), "");
static_assert((std::is_same<decltype(fopen("", "")), FILE*>::value), "");
@ -148,7 +150,11 @@ int main(int, char**)
static_assert((std::is_same<decltype(getc(fp)), int>::value), "");
static_assert((std::is_same<decltype(getchar()), int>::value), "");
#if TEST_STD_VER < 14
TEST_DIAGNOSTIC_PUSH
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
static_assert((std::is_same<decltype(gets(cp)), char*>::value), "");
TEST_DIAGNOSTIC_POP
#endif
static_assert((std::is_same<decltype(putc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(putchar(0)), int>::value), "");

View File

@ -14,12 +14,6 @@
#include "test_macros.h"
// As of 1/10/2015 clang emits a -Wnonnull warnings even if the warning occurs
// in an unevaluated context. For this reason we manually suppress the warning.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wnonnull"
#endif
#ifdef abs
#error abs is defined
#endif
@ -73,10 +67,8 @@ template <class T>
struct has_abs : decltype(has_abs_imp<T>(0)) {};
void test_abs() {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wabsolute-value"
#endif
TEST_DIAGNOSTIC_PUSH
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wabsolute-value")
static_assert((std::is_same<decltype(abs((float)0)), float>::value), "");
static_assert((std::is_same<decltype(abs((double)0)), double>::value), "");
static_assert(
@ -103,9 +95,7 @@ void test_abs() {
static_assert(!has_abs<unsigned long long>::value, "");
static_assert(!has_abs<size_t>::value, "");
#ifdef __clang__
#pragma clang diagnostic pop
#endif
TEST_DIAGNOSTIC_POP
assert(abs(-1.) == 1);
}

View File

@ -79,11 +79,7 @@
#include <cstdarg>
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-zero-length"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wformat-zero-length")
int main(int, char**)
{
@ -141,14 +137,21 @@ int main(int, char**)
static_assert((std::is_same<decltype(std::remove("")), int>::value), "");
static_assert((std::is_same<decltype(std::rename("","")), int>::value), "");
static_assert((std::is_same<decltype(std::tmpfile()), std::FILE*>::value), "");
// disable deprecated warnings from the C library
TEST_DIAGNOSTIC_PUSH
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
static_assert((std::is_same<decltype(std::tmpnam(cp)), char*>::value), "");
TEST_DIAGNOSTIC_POP
static_assert((std::is_same<decltype(std::getchar()), int>::value), "");
#if TEST_STD_VER <= 11
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations" // disable the warning from the C library
TEST_DIAGNOSTIC_PUSH
// disable the warning from the C library
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), "");
# pragma GCC diagnostic pop
TEST_DIAGNOSTIC_POP
#endif
static_assert((std::is_same<decltype(std::scanf(" ")), int>::value), "");
static_assert((std::is_same<decltype(std::vscanf(" ",va)), int>::value), "");

View File

@ -25,9 +25,7 @@
// The filesystem specification explicitly allows for self-move on
// the directory iterators. Turn off this warning so we can test it.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wself-move"
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wself-move")
using namespace fs;

View File

@ -25,9 +25,7 @@
// The filesystem specification explicitly allows for self-move on
// the directory iterators. Turn off this warning so we can test it.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wself-move"
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wself-move")
using namespace fs;

View File

@ -196,14 +196,9 @@ Times GetSymlinkTimes(path const& p) {
namespace {
// In some configurations, the comparison is tautological and the test is valid.
// We disable the warning so that we can actually test it regardless. Also, that
// diagnostic is pretty new, so also don't fail if old clang does not support it
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wtautological-constant-compare"
#endif
// We disable the warning so that we can actually test it regardless.
TEST_DIAGNOSTIC_PUSH
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-compare")
static const bool SupportsNegativeTimes = [] {
using namespace std::chrono;
@ -368,9 +363,7 @@ inline bool TimeIsRepresentableByFilesystem(file_time_type tp) {
return true;
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
TEST_DIAGNOSTIC_POP
// Create a sub-second duration using the smallest period the filesystem supports.
file_time_type::duration SubSec(long long val) {

View File

@ -24,9 +24,7 @@
#include "test_macros.h"
// Ignore warning about std::numeric_limits comparisons being tautological.
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wtype-limits"
#endif
TEST_GCC_DIAGNOSTIC_IGNORED("-Wtype-limits")
struct short_container {
uint16_t size() const { return 60000; } // not noexcept

View File

@ -18,13 +18,8 @@
#include "test_macros.h"
#if defined(TEST_COMPILER_CLANG)
#pragma clang diagnostic ignored "-Wliteral-conversion"
#endif
#ifdef TEST_COMPILER_MSVC
#pragma warning(disable: 4244) // conversion from 'X' to 'Y', possible loss of data
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wliteral-conversion")
TEST_MSVC_DIAGNOSTIC_IGNORED(4244) // conversion from 'X' to 'Y', possible loss of data
int main(int, char**)
{

View File

@ -14,12 +14,6 @@
#include "test_macros.h"
// As of 1/10/2015 clang emits a -Wnonnull warnings even if the warning occurs
// in an unevaluated context. For this reason we manually suppress the warning.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wnonnull"
#endif
#ifndef EXIT_FAILURE
#error EXIT_FAILURE not defined
#endif
@ -58,10 +52,8 @@ template <class T>
struct has_abs : decltype(has_abs_imp<T>(0)) {};
void test_abs() {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wabsolute-value"
#endif
TEST_DIAGNOSTIC_PUSH
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wabsolute-value")
static_assert((std::is_same<decltype(std::abs((float)0)), float>::value), "");
static_assert((std::is_same<decltype(std::abs((double)0)), double>::value), "");
static_assert(
@ -88,9 +80,7 @@ void test_abs() {
static_assert(!has_abs<unsigned long long>::value, "");
static_assert(!has_abs<size_t>::value, "");
#ifdef __clang__
#pragma clang diagnostic pop
#endif
TEST_DIAGNOSTIC_POP
assert(std::abs(-1.) == 1);
}

View File

@ -51,19 +51,15 @@ void test_comparisons()
assert(!(nullptr != p));
}
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnull-conversion"
#endif
TEST_DIAGNOSTIC_PUSH
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wnull-conversion")
void test_nullptr_conversions() {
{
bool b(nullptr);
assert(!b);
}
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
TEST_DIAGNOSTIC_POP
int main(int, char**)

View File

@ -13,11 +13,9 @@
#include "test_macros.h"
#if defined(TEST_COMPILER_CLANG) || defined(TEST_COMPILER_GCC)
#pragma GCC diagnostic ignored "-Wsign-compare"
#elif defined(TEST_COMPILER_MSVC)
#pragma warning(disable: 4242 4244) // Various truncation warnings
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244) // Various truncation warnings
#include <cassert>
#include <compare>

View File

@ -19,12 +19,11 @@
#include <cassert>
#include <streambuf>
#include <sstream>
#include "test_iterators.h"
#include "test_macros.h"
#ifdef TEST_COMPILER_MSVC
#pragma warning(disable: 4146) // unary minus operator applied to unsigned type, result still unsigned
#endif
TEST_MSVC_DIAGNOSTIC_IGNORED(4146) // unary minus operator applied to unsigned type, result still unsigned
typedef std::num_get<char, cpp17_input_iterator<const char*> > F;

View File

@ -113,10 +113,9 @@ void test_abs()
{
// See also "abs.pass.cpp"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wabsolute-value"
#endif
TEST_DIAGNOSTIC_PUSH
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wabsolute-value")
static_assert((std::is_same<decltype(std::abs((float)0)), float>::value), "");
static_assert((std::is_same<decltype(std::abs((double)0)), double>::value), "");
static_assert((std::is_same<decltype(std::abs((long double)0)), long double>::value), "");
@ -135,9 +134,8 @@ void test_abs()
static_assert(!has_abs<unsigned long>::value, "");
static_assert(!has_abs<unsigned long long>::value, "");
static_assert(!has_abs<size_t>::value, "");
#ifdef __clang__
#pragma clang diagnostic pop
#endif
TEST_DIAGNOSTIC_POP
assert(std::abs(-1.) == 1);
}

View File

@ -44,10 +44,8 @@ test1()
assert((LCE::min() == (c == 0u ? 1u: 0u)));
#endif
#ifdef TEST_COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable: 4310) // cast truncates constant value
#endif // TEST_COMPILER_MSVC
TEST_DIAGNOSTIC_PUSH
TEST_MSVC_DIAGNOSTIC_IGNORED(4310) // cast truncates constant value
#if TEST_STD_VER >= 11
static_assert((LCE::max() == result_type(m - 1u)), "");
@ -55,9 +53,7 @@ test1()
assert((LCE::max() == result_type(m - 1u)));
#endif
#ifdef TEST_COMPILER_MSVC
#pragma warning(pop)
#endif // TEST_COMPILER_MSVC
TEST_DIAGNOSTIC_POP
static_assert((LCE::default_seed == 1), "");
where(LCE::multiplier);

View File

@ -11,11 +11,9 @@
#include "test_macros.h"
#if defined(TEST_COMPILER_CLANG) || defined(TEST_COMPILER_GCC)
#pragma GCC diagnostic ignored "-Wsign-compare"
#elif defined(TEST_COMPILER_MSVC)
#pragma warning(disable: 4018 4389) // various "signed/unsigned mismatch"
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_MSVC_DIAGNOSTIC_IGNORED(4018 4389) // various "signed/unsigned mismatch"
// constexpr iota_view(type_identity_t<W> value, type_identity_t<Bound> bound);

View File

@ -11,11 +11,9 @@
#include "test_macros.h"
#if defined(TEST_COMPILER_CLANG) || defined(TEST_COMPILER_GCC)
#pragma GCC diagnostic ignored "-Wsign-compare"
#elif defined(TEST_COMPILER_MSVC)
#pragma warning(disable: 4018 4389) // various "signed/unsigned mismatch"
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_MSVC_DIAGNOSTIC_IGNORED(4018 4389) // various "signed/unsigned mismatch"
// constexpr auto end() const;
// constexpr iterator end() const requires same_as<W, Bound>;

View File

@ -13,11 +13,9 @@
#include "test_macros.h"
#if defined(TEST_COMPILER_CLANG) || defined(TEST_COMPILER_GCC)
#pragma GCC diagnostic ignored "-Wsign-compare"
#elif defined(TEST_COMPILER_MSVC)
#pragma warning(disable: 4018) // various "signed/unsigned mismatch"
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_MSVC_DIAGNOSTIC_IGNORED(4018) // various "signed/unsigned mismatch"
#include <ranges>
#include <cassert>

View File

@ -24,9 +24,8 @@
#include "test_macros.h"
// Prevent warning on the `const NonCopyable()` function type.
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wignored-qualifiers")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wignored-qualifiers")
struct NonCopyable {
NonCopyable() = default;

View File

@ -25,19 +25,13 @@
// Disable the tautological constant evaluation warnings for this test,
// because it's explicitly testing those cases.
#if TEST_HAS_WARNING("-Wconstant-evaluated") && defined(__clang__)
#pragma clang diagnostic ignored "-Wconstant-evaluated"
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wconstant-evaluated")
TEST_MSVC_DIAGNOSTIC_IGNORED(5063)
template <bool> struct InTemplate {};
int main(int, char**)
{
#ifdef __cpp_lib_is_constant_evaluated
#ifdef TEST_COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable: 5063) // 'std::is_constant_evaluated' always evaluates to true in manifestly constant-evaluated expressions
#endif // TEST_COMPILER_MSVC
// Test the signature
{
ASSERT_SAME_TYPE(decltype(std::is_constant_evaluated()), bool);
@ -55,9 +49,5 @@ int main(int, char**)
static int local_static = std::is_constant_evaluated() ? 42 : -1;
assert(local_static == 42);
}
#ifdef TEST_COMPILER_MSVC
#pragma warning(pop)
#endif // TEST_COMPILER_MSVC
#endif // __cpp_lib_is_constant_evaluated
return 0;
}

View File

@ -8,6 +8,8 @@
// UNSUPPORTED: c++03
// ADDITIONAL_COMPILE_FLAGS: -D _LIBCPP_USE_IS_CONVERTIBLE_FALLBACK
// type_traits
// is_convertible
@ -18,11 +20,8 @@
// `__is_convertible` with the same name when clang doesn't.
// Because this test forces the use of the fallback even when clang provides
// it causing a keyword incompatibility.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wkeyword-compat"
#endif
#define _LIBCPP_USE_IS_CONVERTIBLE_FALLBACK
#include "is_convertible.pass.cpp"
#include "test_macros.h"
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wkeyword-compat")
#include "is_convertible.pass.cpp"

View File

@ -10,11 +10,6 @@
// is_destructible
// Prevent warning when testing the Abstract test type.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor"
#endif
#include <type_traits>
#include "test_macros.h"

View File

@ -10,11 +10,6 @@
// is_nothrow_destructible
// Prevent warning when testing the Abstract test type.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor"
#endif
#include <type_traits>
#include "test_macros.h"

View File

@ -10,11 +10,6 @@
// is_trivially_destructible
// Prevent warning when testing the Abstract test type.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor"
#endif
#include <type_traits>
#include "test_macros.h"

View File

@ -18,9 +18,7 @@
#include "test_macros.h"
#ifdef TEST_COMPILER_MSVC
#pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
#endif
TEST_MSVC_DIAGNOSTIC_IGNORED(6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
template <std::size_t N>
void test_char_pointer_ctor()

View File

@ -15,9 +15,7 @@
#include "test_macros.h"
#ifdef TEST_COMPILER_MSVC
#pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
#endif
TEST_MSVC_DIAGNOSTIC_IGNORED(6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
template <std::size_t N>
void test_val_ctor()

View File

@ -16,9 +16,7 @@
#include "../bitset_test_cases.h"
#include "test_macros.h"
#ifdef TEST_COMPILER_MSVC
#pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
#endif
TEST_MSVC_DIAGNOSTIC_IGNORED(6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
template <std::size_t N>
void test_reset_one() {

View File

@ -18,11 +18,9 @@
#include "test_macros.h"
#if defined(TEST_COMPILER_CLANG) || defined(TEST_COMPILER_GCC)
#pragma GCC diagnostic ignored "-Wsign-compare"
#elif defined(TEST_COMPILER_MSVC)
#pragma warning(disable: 4242 4244) // Various truncation warnings
#endif
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244)
#include <cassert>
#include <compare>

View File

@ -180,10 +180,9 @@ struct roundtrip_test_base
r2 = from_chars(buf, r.ptr, x, args...);
#ifdef TEST_COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant
#endif // TEST_COMPILER_MSVC
TEST_DIAGNOSTIC_PUSH
TEST_MSVC_DIAGNOSTIC_IGNORED(4127) // conditional expression is constant
if (std::is_signed<T>::value && v < 0 && std::is_unsigned<X>::value)
{
assert(x == 0xc);
@ -196,9 +195,8 @@ struct roundtrip_test_base
assert(r2.ptr == r.ptr);
assert(r2.ec == std::errc::result_out_of_range);
}
#ifdef TEST_COMPILER_MSVC
#pragma warning(pop)
#endif // TEST_COMPILER_MSVC
TEST_DIAGNOSTIC_POP
}
}

View File

@ -347,17 +347,13 @@ public:
const bool MemCounter::disable_checking = false;
#endif
#ifdef TEST_COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable: 4640) // '%s' construction of local static object is not thread safe (/Zc:threadSafeInit-)
#endif // TEST_COMPILER_MSVC
TEST_DIAGNOSTIC_PUSH
TEST_MSVC_DIAGNOSTIC_IGNORED(4640) // '%s' construction of local static object is not thread safe (/Zc:threadSafeInit-)
inline MemCounter* getGlobalMemCounter() {
static MemCounter counter((MemCounter::MemCounterCtorArg_()));
return &counter;
}
#ifdef TEST_COMPILER_MSVC
#pragma warning(pop)
#endif
TEST_DIAGNOSTIC_POP
MemCounter &globalMemCounter = *getGlobalMemCounter();

View File

@ -23,11 +23,6 @@
#include <ciso646>
#endif
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wvariadic-macros"
#endif
#define TEST_STRINGIZE_IMPL(x) #x
#define TEST_STRINGIZE(x) TEST_STRINGIZE_IMPL(x)
@ -398,8 +393,30 @@ inline void DoNotOptimize(Tp const& value) {
# define TEST_HAS_NO_INCOMPLETE_RANGES
#endif
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#if defined(TEST_COMPILER_CLANG)
# define TEST_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
# define TEST_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
# define TEST_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(TEST_STRINGIZE(clang diagnostic ignored str))
# define TEST_GCC_DIAGNOSTIC_IGNORED(str)
# define TEST_MSVC_DIAGNOSTIC_IGNORED(num)
#elif defined(TEST_COMPILER_GCC)
# define TEST_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
# define TEST_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
# define TEST_CLANG_DIAGNOSTIC_IGNORED(str)
# define TEST_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(TEST_STRINGIZE(GCC diagnostic ignored str))
# define TEST_MSVC_DIAGNOSTIC_IGNORED(num)
#elif defined(TEST_COMPILER_MSVC)
# define TEST_DIAGNOSTIC_PUSH _Pragma("warning(push)")
# define TEST_DIAGNOSTIC_POP _Pragma("warning(pop)")
# define TEST_CLANG_DIAGNOSTIC_IGNORED(str)
# define TEST_GCC_DIAGNOSTIC_IGNORED(str)
# define TEST_MSVC_DIAGNOSTIC_IGNORED(num) _Pragma(TEST_STRINGIZE(warning(disable: num)))
#else
# define TEST_DIAGNOSTIC_PUSH
# define TEST_DIAGNOSTIC_POP
# define TEST_CLANG_DIAGNOSTIC_IGNORED(str)
# define TEST_GCC_DIAGNOSTIC_IGNORED(str)
# define TEST_MSVC_DIAGNOSTIC_IGNORED(num)
#endif
#endif // SUPPORT_TEST_MACROS_HPP

View File

@ -134,11 +134,6 @@ void doIncompleteTypeTest(int expect_alive, Args&&... ctor_args) {
StoresIncomplete<IncompleteT, Del>::~StoresIncomplete() {}
#
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wvariadic-macros"
#endif
#if TEST_STD_VER >= 11
#define DEFINE_AND_RUN_IS_INCOMPLETE_TEST(...) \
static int is_incomplete_test() { __VA_ARGS__ return 0; } \
@ -149,8 +144,4 @@ void doIncompleteTypeTest(int expect_alive, Args&&... ctor_args) {
INCOMPLETE_TEST_EPILOGUE()
#endif
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#endif // TEST_SUPPORT_UNIQUE_PTR_TEST_HELPER_H