diff --git a/CMakeLists.txt b/CMakeLists.txt index ad9131a..d893b0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,9 +35,9 @@ if (SPIRV_REFLECT_EXECUTABLE) ${CMAKE_CURRENT_SOURCE_DIR}/common/output_stream.cpp) target_compile_options(spirv-reflect PRIVATE $<$:/W4 /WX> - $<$:-Wall -Werror> - $<$:-Wall -Werror> - $<$:-Wall -Werror>) + $<$:-Wall -Wextra -Wpedantic -Werror> + $<$:-Wall -Wextra -Wpedantic -Werror> + $<$:-Wall -Wextra -Wpedantic -Werror>) if (SPIRV_REFLECT_ENABLE_ASSERTS) target_compile_definitions(spirv-reflect PRIVATE SPIRV_REFLECT_ENABLE_ASSERTS) endif() @@ -66,9 +66,9 @@ if (SPIRV_REFLECT_EXECUTABLE) ${CMAKE_CURRENT_SOURCE_DIR}/common/output_stream.cpp) target_compile_options(spirv-reflect-pp PRIVATE $<$:/W4 /WX> - $<$:-Wall -Werror> - $<$:-Wall -Werror> - $<$:-Wall -Werror>) + $<$:-Wall -Wextra -Wpedantic -Werror> + $<$:-Wall -Wextra -Wpedantic -Werror> + $<$:-Wall -Wextra -Wpedantic -Werror>) if (SPIRV_REFLECT_ENABLE_ASSERTS) target_compile_definitions(spirv-reflect-pp PRIVATE SPIRV_REFLECT_ENABLE_ASSERTS) endif() diff --git a/common/output_stream.cpp b/common/output_stream.cpp index 4cd8078..50b50e2 100644 --- a/common/output_stream.cpp +++ b/common/output_stream.cpp @@ -1521,11 +1521,11 @@ void StreamWriteEntryPoint(std::ostream& os, const SpvReflectEntryPoint& obj, co if (obj.shader_stage == SPV_REFLECT_SHADER_STAGE_COMPUTE_BIT) { os << "\n"; os << "local size : " - << "(" << (obj.local_size.x == SPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT ? "Spec Constant" : std::to_string(obj.local_size.x)) + << "(" << (obj.local_size.x == (uint32_t)SPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT ? "Spec Constant" : std::to_string(obj.local_size.x)) << ", " - << (obj.local_size.y == SPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT ? "Spec Constant" : std::to_string(obj.local_size.y)) + << (obj.local_size.y == (uint32_t)SPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT ? "Spec Constant" : std::to_string(obj.local_size.y)) << ", " - << (obj.local_size.z == SPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT ? "Spec Constant" : std::to_string(obj.local_size.z)) + << (obj.local_size.z == (uint32_t)SPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT ? "Spec Constant" : std::to_string(obj.local_size.z)) << ")"; } } diff --git a/spirv_reflect.c b/spirv_reflect.c index 113e500..446a451 100644 --- a/spirv_reflect.c +++ b/spirv_reflect.c @@ -52,11 +52,11 @@ enum { }; enum { - INVALID_VALUE = 0xFFFFFFFF, + INVALID_VALUE = (int)0xFFFFFFFF, }; enum { - MAX_NODE_NAME_LENGTH = 1024, + MAX_NODE_NAME_LENGTH = 1024, // Number of unique PhysicalStorageBuffer structs tracked to detect recursion MAX_RECURSIVE_PHYSICAL_POINTER_CHECK = 128, }; @@ -1345,7 +1345,7 @@ static SpvReflectResult ParseMemberCounts(SpvReflectPrvParser* p_parser) { continue; } - if (member_index == INVALID_VALUE) { + if (member_index == (uint32_t)INVALID_VALUE) { return SPV_REFLECT_RESULT_ERROR_RANGE_EXCEEDED; } @@ -1779,7 +1779,7 @@ static SpvReflectResult ParseType(SpvReflectPrvParser* p_parser, SpvReflectPrvNo SpvReflectTypeDescription* p_member_type = &(p_type->members[i]); p_member_type->id = (uint32_t)INVALID_VALUE; p_member_type->op = (SpvOp)INVALID_VALUE; - p_member_type->storage_class = (SpvStorageClass)INVALID_VALUE; + p_member_type->storage_class = INVALID_VALUE; } } else { result = SPV_REFLECT_RESULT_ERROR_ALLOC_FAILED; @@ -1789,7 +1789,7 @@ static SpvReflectResult ParseType(SpvReflectPrvParser* p_parser, SpvReflectPrvNo if (result == SPV_REFLECT_RESULT_SUCCESS) { // Since the parse descends on type information, these will get overwritten // if not guarded against assignment. Only assign if the id is invalid. - if (p_type->id == INVALID_VALUE) { + if (p_type->id == (uint32_t)INVALID_VALUE) { p_type->id = p_node->result_id; p_type->op = p_node->op; p_type->decoration_flags = 0; @@ -2058,7 +2058,7 @@ static SpvReflectResult ParseTypes(SpvReflectPrvParser* p_parser, SpvReflectShad SpvReflectTypeDescription* p_type = &(p_module->_internal->type_descriptions[i]); p_type->id = (uint32_t)INVALID_VALUE; p_type->op = (SpvOp)INVALID_VALUE; - p_type->storage_class = (SpvStorageClass)INVALID_VALUE; + p_type->storage_class = INVALID_VALUE; } size_t type_index = 0; @@ -2144,7 +2144,7 @@ static SpvReflectResult ParseDescriptorBindings(SpvReflectPrvParser* p_parser, S (p_node->storage_class != SpvStorageClassUniformConstant))) { continue; } - if ((p_node->decorations.set.value == INVALID_VALUE) || (p_node->decorations.binding.value == INVALID_VALUE)) { + if ((p_node->decorations.set.value == (uint32_t)INVALID_VALUE) || (p_node->decorations.binding.value == (uint32_t)INVALID_VALUE)) { continue; } @@ -2179,7 +2179,7 @@ static SpvReflectResult ParseDescriptorBindings(SpvReflectPrvParser* p_parser, S (p_node->storage_class != SpvStorageClassUniformConstant))) { continue; } - if ((p_node->decorations.set.value == INVALID_VALUE) || (p_node->decorations.binding.value == INVALID_VALUE)) { + if ((p_node->decorations.set.value == (uint32_t)INVALID_VALUE) || (p_node->decorations.binding.value == (uint32_t)INVALID_VALUE)) { continue; } @@ -3446,7 +3446,7 @@ static SpvReflectResult ParseByteAddressBuffer(SpvReflectPrvParser* p_parser, Sp // All arithmetic ops takes 2 operands, assumption is the 2nd operand has the constant UNCHECKED_READU32(p_parser, p_next_node->word_offset + 4, base_id); uint32_t value = GetUint32Constant(p_parser, base_id); - if (value == INVALID_VALUE) { + if (value == (uint32_t)INVALID_VALUE) { return not_found; } @@ -5022,7 +5022,7 @@ const SpvReflectDescriptorSet* spvReflectGetEntryPointDescriptorSet(const SpvRef const SpvReflectInterfaceVariable* spvReflectGetInputVariableByLocation(const SpvReflectShaderModule* p_module, uint32_t location, SpvReflectResult* p_result) { - if (location == INVALID_VALUE) { + if (location == (uint32_t)INVALID_VALUE) { if (IsNotNull(p_result)) { *p_result = SPV_REFLECT_RESULT_ERROR_ELEMENT_NOT_FOUND; } @@ -5052,7 +5052,7 @@ const SpvReflectInterfaceVariable* spvReflectGetInputVariable(const SpvReflectSh const SpvReflectInterfaceVariable* spvReflectGetEntryPointInputVariableByLocation(const SpvReflectShaderModule* p_module, const char* entry_point, uint32_t location, SpvReflectResult* p_result) { - if (location == INVALID_VALUE) { + if (location == (uint32_t)INVALID_VALUE) { if (IsNotNull(p_result)) { *p_result = SPV_REFLECT_RESULT_ERROR_ELEMENT_NOT_FOUND; } @@ -5155,7 +5155,7 @@ const SpvReflectInterfaceVariable* spvReflectGetEntryPointInputVariableBySemanti const SpvReflectInterfaceVariable* spvReflectGetOutputVariableByLocation(const SpvReflectShaderModule* p_module, uint32_t location, SpvReflectResult* p_result) { - if (location == INVALID_VALUE) { + if (location == (uint32_t)INVALID_VALUE) { if (IsNotNull(p_result)) { *p_result = SPV_REFLECT_RESULT_ERROR_ELEMENT_NOT_FOUND; } @@ -5185,7 +5185,7 @@ const SpvReflectInterfaceVariable* spvReflectGetOutputVariable(const SpvReflectS const SpvReflectInterfaceVariable* spvReflectGetEntryPointOutputVariableByLocation(const SpvReflectShaderModule* p_module, const char* entry_point, uint32_t location, SpvReflectResult* p_result) { - if (location == INVALID_VALUE) { + if (location == (uint32_t)INVALID_VALUE) { if (IsNotNull(p_result)) { *p_result = SPV_REFLECT_RESULT_ERROR_ELEMENT_NOT_FOUND; } diff --git a/spirv_reflect.h b/spirv_reflect.h index eea30bd..495491d 100644 --- a/spirv_reflect.h +++ b/spirv_reflect.h @@ -523,7 +523,7 @@ typedef struct SpvReflectDescriptorSet { } SpvReflectDescriptorSet; typedef enum SpvReflectExecutionModeValue { - SPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT = 0xFFFFFFFF // specialization constant + SPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT = (int)0xFFFFFFFF // specialization constant } SpvReflectExecutionModeValue; /*! @struct SpvReflectEntryPoint