Skip to content

[libc++][test] Use TEST_MEOW_DIAGNOSTIC_IGNORED instead of ADDITIONAL_COMPILE_FLAGS #75133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
// constexpr borrowed_iterator_t<R>
// ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {});

#include "test_macros.h"

// MSVC warning C4244: 'argument': conversion from 'const _Ty2' to 'T', possible loss of data
TEST_MSVC_DIAGNOSTIC_IGNORED(4244)

#include <algorithm>
#include <array>
#include <cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@
// constexpr bool // constexpr after c++17
// equal(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);

#include "test_macros.h"

// We test the cartesian product, so we sometimes compare differently signed types
// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
// MSVC warning C4242: 'argument': conversion from 'int' to 'const _Ty', possible loss of data
// MSVC warning C4244: 'argument': conversion from 'wchar_t' to 'const _Ty', possible loss of data
// MSVC warning C4389: '==': signed/unsigned mismatch
TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244 4389)

#include <algorithm>
#include <cassert>
#include <functional>

#include "test_iterators.h"
#include "test_macros.h"
#include "type_algorithms.h"

template <class UnderlyingType, class Iter1>
Expand Down Expand Up @@ -58,6 +64,10 @@ struct Test {
struct TestNarrowingEqualTo {
template <class UnderlyingType>
TEST_CONSTEXPR_CXX20 void operator()() {
TEST_DIAGNOSTIC_PUSH
// MSVC warning C4310: cast truncates constant value
TEST_MSVC_DIAGNOSTIC_IGNORED(4310)

UnderlyingType a[] = {
UnderlyingType(0x1000),
UnderlyingType(0x1001),
Expand All @@ -71,6 +81,8 @@ struct TestNarrowingEqualTo {
UnderlyingType(0x1603),
UnderlyingType(0x1604)};

TEST_DIAGNOSTIC_POP

assert(std::equal(a, a + 5, b, std::equal_to<char>()));
#if TEST_STD_VER >= 14
assert(std::equal(a, a + 5, b, b + 5, std::equal_to<char>()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@
//
//===----------------------------------------------------------------------===//

// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare

// <algorithm>

// template<InputIterator Iter, class T>
// requires HasEqualTo<Iter::value_type, T>
// constexpr Iter // constexpr after C++17
// find(Iter first, Iter last, const T& value);

#include "test_macros.h"

TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
// MSVC warning C4389: '==': signed/unsigned mismatch
TEST_MSVC_DIAGNOSTIC_IGNORED(4389)

#include <algorithm>
#include <cassert>
#include <vector>
#include <type_traits>

#include "test_macros.h"
#include "test_iterators.h"
#include "type_algorithms.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// UNSUPPORTED: c++03, c++11, c++14, c++17

// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare

// template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
// requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
// constexpr I ranges::find(I first, S last, const T& value, Proj proj = {});
Expand All @@ -20,6 +18,14 @@
// constexpr borrowed_iterator_t<R>
// ranges::find(R&& r, const T& value, Proj proj = {});

#include "test_macros.h"

TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
// MSVC warning C4242: 'argument': conversion from 'const _Ty' to 'ElementT', possible loss of data
// MSVC warning C4244: 'argument': conversion from 'const _Ty' to 'ElementT', possible loss of data
TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244)

#include <algorithm>
#include <array>
#include <cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ void test() {

TEST_IGNORE_NODISCARD a.is_lock_free();

TEST_DIAGNOSTIC_PUSH
// MSVC warning C4197: 'volatile std::atomic<operator_hijacker>': top-level volatile in cast is ignored
TEST_MSVC_DIAGNOSTIC_IGNORED(4197)

TEST_IGNORE_NODISCARD T();
TEST_IGNORE_NODISCARD T(v);

TEST_DIAGNOSTIC_POP

TEST_IGNORE_NODISCARD a.load();
TEST_IGNORE_NODISCARD static_cast<typename T::value_type>(a);
a.store(v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,16 @@ void test() {

a.store(v);
a = v;

TEST_DIAGNOSTIC_PUSH
// MSVC warning C4197: 'volatile std::atomic<operator_hijacker *>': top-level volatile in cast is ignored
TEST_MSVC_DIAGNOSTIC_IGNORED(4197)

TEST_IGNORE_NODISCARD T();
TEST_IGNORE_NODISCARD T(v);

TEST_DIAGNOSTIC_POP

TEST_IGNORE_NODISCARD a.load();
TEST_IGNORE_NODISCARD static_cast<typename T::value_type>(a);
TEST_IGNORE_NODISCARD* a;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@

// UNSUPPORTED: c++03, c++11, c++14, c++17

// We voluntarily use std::default_initializable on types that have redundant
// or ignored cv-qualifiers -- don't warn about it.
// ADDITIONAL_COMPILE_FLAGS: -Wno-ignored-qualifiers

// template<class T>
// concept default_initializable = constructible_from<T> &&
// requires { T{}; } &&
// is-default-initializable<T>;

#include "test_macros.h"

// We voluntarily use std::default_initializable on types that have redundant
// or ignored cv-qualifiers -- don't warn about it.
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wignored-qualifiers")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wignored-qualifiers")

#include <array>
#include <concepts>
#include <deque>
Expand All @@ -34,8 +37,6 @@
#include <unordered_set>
#include <vector>

#include "test_macros.h"

struct Empty {};

struct CtorDefaulted {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers

// <map>

// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23

#include "test_macros.h"

// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")

#include <map>

#include "../../../insert_range_maps_sets.h"
#include "test_macros.h"

int main(int, char**) {
// Note: we want to use a pair with non-const elements for input (an assignable type is a lot more convenient) but
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers

// <map>

// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23

#include "test_macros.h"

// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")

#include <map>

#include "../../../insert_range_maps_sets.h"
#include "test_macros.h"

int main(int, char**) {
// Note: we want to use a pair with non-const elements for input (an assignable type is a lot more convenient) but
Expand All @@ -38,4 +41,3 @@ int main(int, char**) {

return 0;
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers

// <set>

// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23

#include "test_macros.h"

// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")

#include <set>

#include "../../insert_range_maps_sets.h"
#include "test_macros.h"

int main(int, char**) {
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers

// <set>

// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23

#include "test_macros.h"

// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")

#include <set>

#include "../../insert_range_maps_sets.h"
#include "test_macros.h"

int main(int, char**) {
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

// template <size_t I, class T, size_t N> T& get(array<T, N>& a);

#include "test_macros.h"

// Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify.
// ADDITIONAL_COMPILE_FLAGS: -Wno-array-bounds
TEST_CLANG_DIAGNOSTIC_IGNORED("-Warray-bounds")
TEST_GCC_DIAGNOSTIC_IGNORED("-Warray-bounds")

#include <array>
#include <cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers

// <unordered_map>

// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23

#include "test_macros.h"

// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")

#include <unordered_map>

#include "../../../insert_range_maps_sets.h"
#include "test_macros.h"

int main(int, char**) {
// Note: we want to use a pair with non-const elements for input (an assignable type is a lot more convenient) but
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers

// <unordered_map>

// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23

#include "test_macros.h"

// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")

#include <unordered_map>

#include "../../../insert_range_maps_sets.h"
#include "test_macros.h"

int main(int, char**) {
// Note: we want to use a pair with non-const elements for input (an assignable type is a lot more convenient) but
Expand All @@ -38,4 +41,3 @@ int main(int, char**) {

return 0;
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers

// <set>

// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23

#include "test_macros.h"

// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")

#include <unordered_set>

#include "../../insert_range_maps_sets.h"
#include "test_macros.h"

int main(int, char**) {
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
Expand All @@ -34,4 +37,3 @@ int main(int, char**) {

return 0;
}

Loading