Skip to content

Commit

Permalink
Fix narrowing errors in compiler and spirv_new
Browse files Browse the repository at this point in the history
Contributes #787

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
  • Loading branch information
ellnor01 committed Apr 28, 2021
1 parent b5ea536 commit 25983c6
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 16 deletions.
3 changes: 0 additions & 3 deletions test_conformance/compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
set(MODULE_NAME COMPILER)

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
Expand Down
8 changes: 4 additions & 4 deletions test_conformance/compiler/test_preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int test_preprocessor_define_udef(cl_device_id deviceID, cl_context context, cl_
error = clEnqueueWriteBuffer(queue, buffer[0], CL_TRUE, 0, num_elements*sizeof(cl_int), srcData, 0, NULL, NULL);
test_error(error, "clEnqueueWriteBuffer failed");

size_t threads[3] = {num_elements, 0, 0};
size_t threads[3] = { (size_t)num_elements, 0, 0 };
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0, NULL, NULL);
test_error(error, "clEnqueueNDRangeKernel failed");

Expand Down Expand Up @@ -175,7 +175,7 @@ int test_preprocessor_include(cl_device_id deviceID, cl_context context, cl_comm
error = clSetKernelArg(kernel, 1, sizeof(buffer[1]), &buffer[1]);
test_error(error, "clSetKernelArg failed");

size_t threads[3] = {num_elements, 0, 0};
size_t threads[3] = { (size_t)num_elements, 0, 0 };
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0, NULL, NULL);
test_error(error, "clEnqueueNDRangeKernel failed");

Expand Down Expand Up @@ -272,7 +272,7 @@ int test_preprocessor_line_error(cl_device_id deviceID, cl_context context, cl_c
error = clSetKernelArg(kernel, 0, sizeof(buffer[0]), &buffer[0]);
test_error(error, "clSetKernelArg failed");

size_t threads[3] = {num_elements, 0, 0};
size_t threads[3] = { (size_t)num_elements, 0, 0 };
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0, NULL, NULL);
test_error(error, "clEnqueueNDRangeKernel failed");

Expand Down Expand Up @@ -313,7 +313,7 @@ int test_preprocessor_pragma(cl_device_id deviceID, cl_context context, cl_comma
error = clSetKernelArg(kernel, 0, sizeof(buffer[0]), &buffer[0]);
test_error(error, "clSetKernelArg failed");

size_t threads[3] = {num_elements, 0, 0};
size_t threads[3] = { (size_t)num_elements, 0, 0 };
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0, NULL, NULL);
test_error(error, "clEnqueueNDRangeKernel failed");

Expand Down
4 changes: 0 additions & 4 deletions test_conformance/spirv_new/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
set(MODULE_NAME SPIRV_NEW)
set(CMAKE_CXX_STANDARD 11)

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
add_cxx_flag_if_supported(-Wno-narrowing)
endif()

file(GLOB SPIRV_NEW_SOURCES "*.cpp")

set(TEST_HARNESS_SOURCES
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/spirv_new/test_op_composite_construct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ TEST_SPIRV_FUNC(op_composite_construct_struct)
typedef AbstractStruct2<int, char> CustomType1;
typedef AbstractStruct2<cl_int2, CustomType1> CustomType2;

CustomType1 value1 = {2100483600, 128};
CustomType1 value1 = { 2100483600, (char)128 };
cl_int2 intvals = {2100480000, 2100480000};
CustomType2 value2 = {intvals, value1};

Expand Down
4 changes: 2 additions & 2 deletions test_conformance/spirv_new/test_op_constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ TEST_SPIRV_FUNC(op_constant_struct_int_float_simple)

TEST_SPIRV_FUNC(op_constant_struct_int_char_simple)
{
AbstractStruct2<int, char> value = {2100483600, 128};
AbstractStruct2<int, char> value = { 2100483600, (char)128 };
std::vector<AbstractStruct2<int, char> > results(256, value);
return test_constant(deviceID, context, queue, "constant_struct_int_char_simple", results);
}
Expand All @@ -129,7 +129,7 @@ TEST_SPIRV_FUNC(op_constant_struct_struct_simple)
typedef AbstractStruct2<int, char> CustomType1;
typedef AbstractStruct2<cl_int2, CustomType1> CustomType2;

CustomType1 value1 = {2100483600, 128};
CustomType1 value1 = { 2100483600, (char)128 };
cl_int2 intvals = {2100480000, 2100480000};
CustomType2 value2 = {intvals, value1};

Expand Down
4 changes: 2 additions & 2 deletions test_conformance/spirv_new/test_op_copy_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ TEST_SPIRV_FUNC(op_copy_struct_int_float_simple)

TEST_SPIRV_FUNC(op_copy_struct_int_char_simple)
{
AbstractStruct2<int, char> value = {2100483600, 128};
AbstractStruct2<int, char> value = { 2100483600, (char)128 };
std::vector<AbstractStruct2<int, char> > results(256, value);
return test_copy(deviceID, context, queue, "copy_struct_int_char_simple", results);
}
Expand All @@ -125,7 +125,7 @@ TEST_SPIRV_FUNC(op_copy_struct_struct_simple)
typedef AbstractStruct2<int, char> CustomType1;
typedef AbstractStruct2<cl_int2, CustomType1> CustomType2;

CustomType1 value1 = {2100483600, 128};
CustomType1 value1 = { 2100483600, (char)128 };
cl_int2 intvals = {2100480000, 2100480000};
CustomType2 value2 = {intvals, value1};

Expand Down

0 comments on commit 25983c6

Please sign in to comment.