Skip to content
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

Drop thrusts diagnostic suppression warnings #2392

Merged
merged 2 commits into from
Sep 16, 2024
Merged
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
5 changes: 3 additions & 2 deletions thrust/testing/binary_search.cu
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

#include <unittest/unittest.h>

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data

//////////////////////
// Scalar Functions //
Expand Down Expand Up @@ -263,7 +264,7 @@ void TestScalarEqualRangeDispatchImplicit()
}
DECLARE_UNITTEST(TestScalarEqualRangeDispatchImplicit);

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END
_CCCL_DIAG_POP

void TestBoundsWithBigIndexesHelper(int magnitude)
{
Expand Down
5 changes: 3 additions & 2 deletions thrust/testing/counting_iterator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

#include <unittest/unittest.h>

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data

// ensure that we properly support thrust::counting_iterator from cuda::std
void test_iterator_traits()
Expand Down Expand Up @@ -245,4 +246,4 @@ void TestCountingIteratorDifference()
}
DECLARE_UNITTEST(TestCountingIteratorDifference);

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END
_CCCL_DIAG_POP
5 changes: 3 additions & 2 deletions thrust/testing/dereference.cu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

#include <unittest/unittest.h>

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data

template <typename Iterator1, typename Iterator2>
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
Expand Down Expand Up @@ -106,4 +107,4 @@ void TestDeviceDereferenceTransformedCountingIterator()
}
DECLARE_UNITTEST(TestDeviceDereferenceTransformedCountingIterator);

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END
_CCCL_DIAG_POP
5 changes: 3 additions & 2 deletions thrust/testing/fill.cu
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

#include <unittest/unittest.h>

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data

template <class Vector>
void TestFillSimple()
Expand Down Expand Up @@ -446,4 +447,4 @@ void TestFillNDispatchImplicit()
}
DECLARE_UNITTEST(TestFillNDispatchImplicit);

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END
_CCCL_DIAG_POP
5 changes: 3 additions & 2 deletions thrust/testing/for_each.cu
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#include <unittest/unittest.h>

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data

template <typename T>
class mark_present_for_each
Expand Down Expand Up @@ -354,7 +355,7 @@ void TestForEachNWithLargeTypes()
}
DECLARE_UNITTEST(TestForEachNWithLargeTypes);

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END
_CCCL_DIAG_POP

struct only_set_when_expected
{
Expand Down
5 changes: 3 additions & 2 deletions thrust/testing/functional.cu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

#include <unittest/unittest.h>

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data

// There is a unfortunate miscompilation of the gcc-11 vectorizer leading to OOB writes
// Adding this attribute suffices that this miscompilation does not appear anymore
Expand Down Expand Up @@ -366,4 +367,4 @@ DECLARE_VECTOR_UNITTEST(TestNot2);

#endif // Weird GCC11 failure case

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END
_CCCL_DIAG_POP
5 changes: 3 additions & 2 deletions thrust/testing/gather.cu
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#include <unittest/unittest.h>

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data

template <class Vector>
void TestGatherSimple()
Expand Down Expand Up @@ -361,4 +362,4 @@ void TestGatherCountingIterator()
}
DECLARE_INTEGRAL_VECTOR_UNITTEST(TestGatherCountingIterator);

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END
_CCCL_DIAG_POP
5 changes: 3 additions & 2 deletions thrust/testing/generate.cu
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

#include <unittest/unittest.h>

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data

template <typename T>
struct return_value
Expand Down Expand Up @@ -219,4 +220,4 @@ void TestGenerateTuple()
};
DECLARE_UNITTEST(TestGenerateTuple);

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END
_CCCL_DIAG_POP
5 changes: 3 additions & 2 deletions thrust/testing/random.cu
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ void TestRanlux48Unequal()
}
DECLARE_UNITTEST(TestRanlux48Unequal);

THRUST_DISABLE_MSVC_WARNING_BEGIN(4305) // truncation warning
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4305) // truncation warning
template <typename Distribution, typename Validator>
void ValidateDistributionCharacteristic()
{
Expand Down Expand Up @@ -732,7 +733,7 @@ void ValidateDistributionCharacteristic()

ASSERT_EQUAL(true, d[0]);
}
THRUST_DISABLE_MSVC_WARNING_END(4305)
_CCCL_DIAG_POP

template <typename Distribution>
void TestDistributionSaveRestore()
Expand Down
5 changes: 3 additions & 2 deletions thrust/testing/unittest/testframework.cu
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,11 @@ bool UnitTestDriver::run_tests(std::vector<UnitTest*>& tests_to_run, const Argum
{
std::time_t start_time = std::time(0);

THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4800) // Forcing value to bool
bool verbose = kwargs.count("verbose");
bool concise = kwargs.count("concise");
THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_END
_CCCL_DIAG_POP

std::vector<TestResult> test_results;

Expand Down
10 changes: 8 additions & 2 deletions thrust/testing/vector.cu
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ void TestVectorToAndFromHostVector()

ASSERT_EQUAL(v, h);

THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING(v = v);
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_CLANG("-Wself-assign")
v = v;
_CCCL_DIAG_POP

ASSERT_EQUAL(v, h);

Expand Down Expand Up @@ -330,7 +333,10 @@ void TestVectorToAndFromDeviceVector()

ASSERT_EQUAL(v, h);

THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING(v = v);
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_CLANG("-Wself-assign")
v = v;
_CCCL_DIAG_POP

ASSERT_EQUAL(v, h);

Expand Down
100 changes: 0 additions & 100 deletions thrust/thrust/detail/config/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,103 +117,3 @@
#else
# define THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE THRUST_FALSE
#endif // _OPENMP

#if defined(_CCCL_COMPILER_MSVC) && !defined(__CUDA_ARCH__)
# define THRUST_DISABLE_MSVC_WARNING_BEGIN(x) __pragma(warning(push)) __pragma(warning(disable : x)) /**/
# define THRUST_DISABLE_MSVC_WARNING_END(x) __pragma(warning(pop)) /**/
#else
# define THRUST_DISABLE_MSVC_WARNING_BEGIN(x)
# define THRUST_DISABLE_MSVC_WARNING_END(x)
#endif

#if defined(_CCCL_COMPILER_CLANG) && !defined(__CUDA_ARCH__)
# define THRUST_IGNORE_CLANG_WARNING_IMPL(x) \
THRUST_PP_STRINGIZE(clang diagnostic ignored x) \
/**/
# define THRUST_IGNORE_CLANG_WARNING(x) \
THRUST_IGNORE_CLANG_WARNING_IMPL(THRUST_PP_STRINGIZE(x)) \
/**/

# define THRUST_DISABLE_CLANG_WARNING_BEGIN(x) \
_Pragma("clang diagnostic push") _Pragma(THRUST_IGNORE_CLANG_WARNING(x)) /**/
# define THRUST_DISABLE_CLANG_WARNING_END(x) _Pragma("clang diagnostic pop") /**/
#else
# define THRUST_DISABLE_CLANG_WARNING_BEGIN(x)
# define THRUST_DISABLE_CLANG_WARNING_END(x)
#endif

#if defined(_CCCL_COMPILER_GCC) && !defined(__CUDA_ARCH__)
# define THRUST_IGNORE_GCC_WARNING_IMPL(x) \
THRUST_PP_STRINGIZE(GCC diagnostic ignored x) \
/**/
# define THRUST_IGNORE_GCC_WARNING(x) \
THRUST_IGNORE_GCC_WARNING_IMPL(THRUST_PP_STRINGIZE(x)) \
/**/

# define THRUST_DISABLE_GCC_WARNING_BEGIN(x) _Pragma("GCC diagnostic push") _Pragma(THRUST_IGNORE_GCC_WARNING(x)) /**/
# define THRUST_DISABLE_GCC_WARNING_END(x) _Pragma("GCC diagnostic pop") /**/
#else
# define THRUST_DISABLE_GCC_WARNING_BEGIN(x)
# define THRUST_DISABLE_GCC_WARNING_END(x)
#endif

#if defined(_CCCL_COMPILER_ICC) && !defined(__CUDA_ARCH__)
# define THRUST_DISABLE_ICC_WARNING_BEGIN(x) _CCCL_DIAG_PUSH _CCCL_DIAG_SUPPRESS_ICC(x)
# define THRUST_DISABLE_ICC_WARNING_END(x) _CCCL_DIAG_POP
#else
# define THRUST_DISABLE_ICC_WARNING_BEGIN(x)
# define THRUST_DISABLE_ICC_WARNING_END(x)
#endif

#define THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN \
THRUST_DISABLE_MSVC_WARNING_BEGIN(4244 4267) \
/**/
#define THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END \
THRUST_DISABLE_MSVC_WARNING_END(4244 4267) \
/**/
#define THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING(x) \
THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN \
x; \
THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END \
/**/

#define THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_BEGIN \
THRUST_DISABLE_MSVC_WARNING_BEGIN(4800) \
/**/
#define THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_END \
THRUST_DISABLE_MSVC_WARNING_END(4800) \
/**/
#define THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING(x) \
THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_BEGIN \
x; \
THRUST_DISABLE_MSVC_FORCING_VALUE_TO_BOOL_WARNING_END \
/**/

// auto-formatting splits -Wself-assign into -Wself - assign
// clang-format off
#define THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_BEGIN \
THRUST_DISABLE_CLANG_WARNING_BEGIN(-Wself-assign)
#define THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_END \
THRUST_DISABLE_CLANG_WARNING_END(-Wself-assign)
// clang-format on
#define THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING(x) \
THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_BEGIN \
x; \
THRUST_DISABLE_CLANG_SELF_ASSIGNMENT_WARNING_END \
/**/

#define THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_BEGIN \
THRUST_DISABLE_CLANG_WARNING_BEGIN(-Wreorder) \
THRUST_DISABLE_GCC_WARNING_BEGIN(-Wreorder) \
THRUST_DISABLE_ICC_WARNING_BEGIN(2407) \
/**/
#define THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_END \
THRUST_DISABLE_CLANG_WARNING_END(-Wreorder) \
THRUST_DISABLE_GCC_WARNING_END(-Wreorder) \
THRUST_DISABLE_ICC_WARNING_END(2407) \
/**/
#define THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING(x) \
THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_BEGIN \
x; \
THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_END \
/**/
5 changes: 3 additions & 2 deletions thrust/thrust/iterator/detail/join_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ class join_iterator
// MSVC 2013 and 2015 incorrectly warning about returning a reference to
// a local/temporary here.
// See goo.gl/LELTNp
THRUST_DISABLE_MSVC_WARNING_BEGIN(4172)
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4172)

_CCCL_HOST_DEVICE typename super_t::reference dereference() const
{
size_type i = *super_t::base();
return (i < m_n1) ? m_iter1[i] : static_cast<typename super_t::reference>(m_iter2[i]);
} // end dereference()

THRUST_DISABLE_MSVC_WARNING_END(4172)
_CCCL_DIAG_POP

size_type m_n1;
RandomAccessIterator1 m_iter1;
Expand Down
5 changes: 3 additions & 2 deletions thrust/thrust/iterator/discard_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
#include <thrust/iterator/detail/discard_iterator_base.h>
#include <thrust/iterator/iterator_facade.h>

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4244 4267) // possible loss of data

THRUST_NAMESPACE_BEGIN

Expand Down Expand Up @@ -162,4 +163,4 @@ make_discard_iterator(discard_iterator<>::difference_type i = discard_iterator<>

THRUST_NAMESPACE_END

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_END
_CCCL_DIAG_POP
5 changes: 3 additions & 2 deletions thrust/thrust/iterator/permutation_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,16 @@ class permutation_iterator : public thrust::detail::permutation_iterator_base<El
// MSVC 2013 and 2015 incorrectly warning about returning a reference to
// a local/temporary here.
// See goo.gl/LELTNp
THRUST_DISABLE_MSVC_WARNING_BEGIN(4172)
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4172)

_CCCL_EXEC_CHECK_DISABLE
_CCCL_HOST_DEVICE typename super_t::reference dereference() const
{
return *(m_element_iterator + *this->base());
}

THRUST_DISABLE_MSVC_WARNING_END(4172)
_CCCL_DIAG_POP

// make friends for the copy constructor
template <typename, typename>
Expand Down
5 changes: 3 additions & 2 deletions thrust/thrust/iterator/transform_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ class transform_iterator
// MSVC 2013 and 2015 incorrectly warning about returning a reference to
// a local/temporary here.
// See goo.gl/LELTNp
THRUST_DISABLE_MSVC_WARNING_BEGIN(4172)
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4172)

_CCCL_EXEC_CHECK_DISABLE
_CCCL_HOST_DEVICE typename super_t::reference dereference() const
Expand All @@ -309,7 +310,7 @@ class transform_iterator
return m_f(x);
}

THRUST_DISABLE_MSVC_WARNING_END(4172)
_CCCL_DIAG_POP

// tag this as mutable per Dave Abrahams in this thread:
// http://lists.boost.org/Archives/boost/2004/05/65332.php
Expand Down
7 changes: 5 additions & 2 deletions thrust/thrust/system/cuda/detail/future.inl
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,10 @@ public:
// address after its been moved into the new signal we're constructing.
// NOTE: NVCC has a bug that causes it to reorder our base class initializers
// in generated host code, which leads to -Wreorder warnings.
THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_BEGIN
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_CLANG("-Wreorder")
_CCCL_DIAG_SUPPRESS_GCC("-Wreorder")
_CCCL_DIAG_SUPPRESS_ICC(2407)
template <typename ComputeContent>
_CCCL_HOST explicit async_addressable_value_with_keep_alives(
unique_stream&& stream, keep_alives_type&& keep_alives, ComputeContent&& compute_content)
Expand All @@ -468,7 +471,7 @@ public:
{
content_ = THRUST_FWD(compute_content)(std::get<0>(this->keep_alives_));
}
THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_END
_CCCL_DIAG_POP

_CCCL_HOST bool valid_content() const noexcept final override
{
Expand Down
Loading
Loading