Skip to content
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
34 changes: 34 additions & 0 deletions cmake/CCCLBuildCompilerTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,40 @@ function(cccl_build_compiler_targets)
append_option_if_available("-Wunused-local-typedefs" cxx_compile_options)
append_option_if_available("-Wvla" cxx_compile_options)

# Clang-only
append_option_if_available("-Wnvcc-compat" cxx_compile_options)
append_option_if_available("-Wimplicit-fallthrough" cxx_compile_options)
append_option_if_available(
"-fdiagnostics-show-template-tree"
cxx_compile_options
)
append_option_if_available("-Wignored-qualifiers" cxx_compile_options)
append_option_if_available(
"-Wmissing-field-initializers"
cxx_compile_options
)
# Inundated with error: ISO C++11 requires at least one argument for the "..." in a
# variadic macro for _CCCL_REQUIRES_EXPR(), so cannot enable this.
#
# append_option_if_available("-pedantic" cxx_compile_options)
append_option_if_available("-Wsign-compare" cxx_compile_options)
append_option_if_available(
"-Warray-bounds-pointer-arithmetic"
cxx_compile_options
)
append_option_if_available("-Wassign-enum" cxx_compile_options)
append_option_if_available("-Wformat-pedantic" cxx_compile_options)
append_option_if_available("-Walloc-size" cxx_compile_options)
append_option_if_available("-Walloc-zero" cxx_compile_options)
append_option_if_available("-Wtsan" cxx_compile_options)
append_option_if_available("-Wenum-conversion" cxx_compile_options)
append_option_if_available("-Wpacked" cxx_compile_options)
# Clang and GCC
append_option_if_available(
"-ftemplate-backtrace-limit=0"
cxx_compile_options
)
append_option_if_available("-fmacro-backtrace-limit=0" cxx_compile_options)
# Disable GNU extensions (flag is clang only)
append_option_if_available("-Wgnu" cxx_compile_options)
append_option_if_available("-Wno-gnu-line-marker" cxx_compile_options) # WAR 3916341
Expand Down
4 changes: 3 additions & 1 deletion cudax/test/execution/test_stream_context.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// Then include the test helpers
#include <thrust/equal.h>

#include <cuda/std/cstddef>

#include <cuda/experimental/container.cuh>
#include <cuda/experimental/memory_resource.cuh>

Expand Down Expand Up @@ -150,7 +152,7 @@ void bulk_on_stream_scheduler()
| ex::bulk(ex::par_unseq, 10, [] __host__ __device__(int i, cuda::std::span<int> data) -> void {
printf("Hello from bulk kernel on device! i = %d\n", i);
CUDAX_CHECK(_is_on_device());
CUDAX_CHECK(i < data.size());
CUDAX_CHECK(static_cast<::cuda::std::size_t>(i) < data.size());
data[i] += 2;
});

Expand Down
3 changes: 3 additions & 0 deletions cudax/test/stf/reclaiming/stream.cu
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ int main(int argc, char** argv)

::std::vector<logical_data<slice<char>>> handles(nblocks);

EXPECT(nblocks > 0);
EXPECT(block_size > 0);

char* h_buffer = new char[nblocks * block_size];

for (int i = 0; i < nblocks; i++)
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__cccl/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
// NVCC does not properly respect [[assume()]], so use __builtin_assume, see nvbug5458663
#if _CCCL_CUDA_COMPILER(NVCC) && _CCCL_DEVICE_COMPILATION()
# define _CCCL_ASSUME(...) __builtin_assume(__VA_ARGS__)
#elif _CCCL_HAS_CPP_ATTRIBUTE(assume)
#elif _CCCL_HAS_CPP_ATTRIBUTE(assume) && (_CCCL_STD_VER >= 2023)
# define _CCCL_ASSUME(...) [[assume(__VA_ARGS__)]]
Comment on lines +81 to 82
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Why shouldn't we use the attribute if the compiler supports it before C++23?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang warns with -Wc++23-compat. I consider this a bug, TBH, that it allows you to use [[assume]] but tells you off for doing so.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care about the -Wc++23-compat warning?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until we start comprehensively testing C++23, I think we should heed the warning. Our CI matrix only goes to C++20 for now.

Note this warning actually only fired due to a previous version of this PR where I also had -pedantic enabled, but that resulted in so many warnings that I turned it off and hope that someone else eventually becomes motivated enough to fix that :)

#else
# define _CCCL_ASSUME(...) _CCCL_BUILTIN_ASSUME(__VA_ARGS__)
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/test/libcudacxx/cuda/ccclrt/algorithm/fill.cu
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ C2H_CCCLRT_TEST("Fill", "[algorithm]")

cuda::std::span<int> span(buffer.data(), 0);
cuda::fill_bytes(_stream, span, fill_byte);
printf("0 sized span: %p\n", span.data());
printf("0 sized span: %p\n", static_cast<void*>(span.data()));
}
}

Expand Down
6 changes: 6 additions & 0 deletions thrust/testing/preprocessor.cu
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ void test_pp_stringize()
, "'hello world'"
);

_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_CLANG("-Wdollar-in-identifier-extension")
ASSERT_EQUAL(
std::string(THRUST_PP_STRINGIZE($%!&<->))
, "$%!&<->"
Expand All @@ -62,6 +64,7 @@ void test_pp_stringize()
std::string(THRUST_PP_STRINGIZE($%!&""<->))
, "$%!&\"\"<->"
);
_CCCL_DIAG_POP

ASSERT_EQUAL(
std::string(THRUST_PP_STRINGIZE(THRUST_PP_STRINGIZE))
Expand Down Expand Up @@ -177,6 +180,8 @@ void test_pp_expand()
, "'hello world'"
);

_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_CLANG("-Wdollar-in-identifier-extension")
ASSERT_EQUAL(
std::string(THRUST_PP_STRINGIZE(THRUST_PP_EXPAND($%!&<->)))
, "$%!&<->"
Expand All @@ -186,6 +191,7 @@ void test_pp_expand()
std::string(THRUST_PP_STRINGIZE(THRUST_PP_EXPAND($%!&""<->)))
, "$%!&\"\"<->"
);
_CCCL_DIAG_POP

ASSERT_EQUAL(
std::string(THRUST_PP_STRINGIZE(THRUST_PP_EXPAND(THRUST_PP_EXPAND)))
Expand Down
Loading