From 77a987d547e2e6262e83bbc106a2400eea6486c5 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Wed, 30 Jul 2025 18:51:54 +0100 Subject: [PATCH] Enable -Wnarrowing in integer_ops test suite (#2465) Fixes #1158 --------- Signed-off-by: Ahmed Hesham --- test_conformance/integer_ops/CMakeLists.txt | 4 --- test_conformance/integer_ops/main.cpp | 34 ++++++++++++++----- .../verification_and_generation_functions.cpp | 8 +++-- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/test_conformance/integer_ops/CMakeLists.txt b/test_conformance/integer_ops/CMakeLists.txt index 9966ca6f..7bc991f8 100644 --- a/test_conformance/integer_ops/CMakeLists.txt +++ b/test_conformance/integer_ops/CMakeLists.txt @@ -1,9 +1,5 @@ set(MODULE_NAME INTEGER_OPS) -if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") - add_cxx_flag_if_supported(-Wno-narrowing) -endif() - set(${MODULE_NAME}_SOURCES main.cpp test_int_basic_ops.cpp diff --git a/test_conformance/integer_ops/main.cpp b/test_conformance/integer_ops/main.cpp index 32849af7..cd90d1bf 100644 --- a/test_conformance/integer_ops/main.cpp +++ b/test_conformance/integer_ops/main.cpp @@ -26,14 +26,32 @@ void fill_test_values( cl_long *outBufferA, cl_long *outBufferB, size_t numElements, MTdata d ) { - static const cl_long sUniqueValues[] = { 0x3333333333333333LL, 0x5555555555555555LL, 0x9999999999999999LL, 0xaaaaaaaaaaaaaaaaLL, 0xccccccccccccccccLL, - 0x3030303030303030LL, 0x5050505050505050LL, 0x9090909090909090LL, 0xa0a0a0a0a0a0a0a0LL, 0xc0c0c0c0c0c0c0c0LL, 0xf0f0f0f0f0f0f0f0LL, - 0x0303030303030303LL, 0x0505050505050505LL, 0x0909090909090909LL, 0x0a0a0a0a0a0a0a0aLL, 0x0c0c0c0c0c0c0c0cLL, 0x0f0f0f0f0f0f0f0fLL, - 0x3300330033003300LL, 0x5500550055005500LL, 0x9900990099009900LL, 0xaa00aa00aa00aa00LL, 0xcc00cc00cc00cc00LL, 0xff00ff00ff00ff00LL, - 0x0033003300330033LL, 0x0055005500550055LL, 0x0099009900990099LL, 0x00aa00aa00aa00aaLL, 0x00cc00cc00cc00ccLL, 0x00ff00ff00ff00ffLL, - 0x3333333300000000LL, 0x5555555500000000LL, 0x9999999900000000LL, 0xaaaaaaaa00000000LL, 0xcccccccc00000000LL, 0xffffffff00000000LL, - 0x0000000033333333LL, 0x0000000055555555LL, 0x0000000099999999LL, 0x00000000aaaaaaaaLL, 0x00000000ccccccccLL, 0x00000000ffffffffLL, - 0x3333000000003333LL, 0x5555000000005555LL, 0x9999000000009999LL, 0xaaaa00000000aaaaLL, 0xcccc00000000ccccLL, 0xffff00000000ffffLL}; + static const cl_long sUniqueValues[] = { + (cl_long)0x3333333333333333LL, (cl_long)0x5555555555555555LL, + (cl_long)0x9999999999999999LL, (cl_long)0xaaaaaaaaaaaaaaaaLL, + (cl_long)0xccccccccccccccccLL, (cl_long)0x3030303030303030LL, + (cl_long)0x5050505050505050LL, (cl_long)0x9090909090909090LL, + (cl_long)0xa0a0a0a0a0a0a0a0LL, (cl_long)0xc0c0c0c0c0c0c0c0LL, + (cl_long)0xf0f0f0f0f0f0f0f0LL, (cl_long)0x0303030303030303LL, + (cl_long)0x0505050505050505LL, (cl_long)0x0909090909090909LL, + (cl_long)0x0a0a0a0a0a0a0a0aLL, (cl_long)0x0c0c0c0c0c0c0c0cLL, + (cl_long)0x0f0f0f0f0f0f0f0fLL, (cl_long)0x3300330033003300LL, + (cl_long)0x5500550055005500LL, (cl_long)0x9900990099009900LL, + (cl_long)0xaa00aa00aa00aa00LL, (cl_long)0xcc00cc00cc00cc00LL, + (cl_long)0xff00ff00ff00ff00LL, (cl_long)0x0033003300330033LL, + (cl_long)0x0055005500550055LL, (cl_long)0x0099009900990099LL, + (cl_long)0x00aa00aa00aa00aaLL, (cl_long)0x00cc00cc00cc00ccLL, + (cl_long)0x00ff00ff00ff00ffLL, (cl_long)0x3333333300000000LL, + (cl_long)0x5555555500000000LL, (cl_long)0x9999999900000000LL, + (cl_long)0xaaaaaaaa00000000LL, (cl_long)0xcccccccc00000000LL, + (cl_long)0xffffffff00000000LL, (cl_long)0x0000000033333333LL, + (cl_long)0x0000000055555555LL, (cl_long)0x0000000099999999LL, + (cl_long)0x00000000aaaaaaaaLL, (cl_long)0x00000000ccccccccLL, + (cl_long)0x00000000ffffffffLL, (cl_long)0x3333000000003333LL, + (cl_long)0x5555000000005555LL, (cl_long)0x9999000000009999LL, + (cl_long)0xaaaa00000000aaaaLL, (cl_long)0xcccc00000000ccccLL, + (cl_long)0xffff00000000ffffLL + }; static cl_long sSpecialValues[ 128 + 128 + 128 + ( sizeof( sUniqueValues ) / sizeof( sUniqueValues[ 0 ] ) ) ] = { 0 }; if( sSpecialValues[ 0 ] == 0 ) diff --git a/test_conformance/integer_ops/verification_and_generation_functions.cpp b/test_conformance/integer_ops/verification_and_generation_functions.cpp index 9a7abf78..4262afb4 100644 --- a/test_conformance/integer_ops/verification_and_generation_functions.cpp +++ b/test_conformance/integer_ops/verification_and_generation_functions.cpp @@ -1370,7 +1370,9 @@ verify_ushort(int test, size_t vector_size, cl_ushort *inptrA, cl_ushort *inptrB void init_ushort_data(uint64_t indx, int num_elements, cl_ushort *input_ptr[], MTdata d) { - static const cl_ushort specialCaseList[] = { 0, -1, 1, CL_SHRT_MAX, CL_SHRT_MAX + 1, CL_USHRT_MAX }; + static const cl_ushort specialCaseList[] = { + 0, (cl_ushort)-1, 1, CL_SHRT_MAX, CL_SHRT_MAX + 1, CL_USHRT_MAX + }; int j; // Set the inputs to a random number @@ -1812,7 +1814,9 @@ verify_uchar(int test, size_t vector_size, cl_uchar *inptrA, cl_uchar *inptrB, c void init_uchar_data(uint64_t indx, int num_elements, cl_uchar *input_ptr[], MTdata d) { - static const cl_uchar specialCaseList[] = { 0, -1, 1, CL_CHAR_MAX, CL_CHAR_MAX + 1, CL_UCHAR_MAX }; + static const cl_uchar specialCaseList[] = { + 0, (cl_uchar)-1, 1, CL_CHAR_MAX, CL_CHAR_MAX + 1, CL_UCHAR_MAX + }; int j; // FIXME: we really should just check every char against every char here