+#define TYPE_RECORD_VALIDATE_OPERAND_MIN_COUNT(min_count) do {\ + if (record->operand_count < (min_count))\ + {\ + WARN("Invalid operand count %u for type code %u, id %zu.\n", record->operand_count, record->code, type_index);\ + return VKD3D_ERROR_INVALID_SHADER;\ + } } while (false) + +#define TYPE_RECORD_VALIDATE_OPERAND_MAX_COUNT(max_count) do {\ + if (record->operand_count > (max_count))\ + WARN("Ignoring %u extra operands for type code %u, id %zu.\n", record->operand_count - (max_count),\ + record->code, type_index); } while (false) + +#define TYPE_RECORD_VALIDATE_OPERAND_COUNT(min_count, max_count) do {\ + TYPE_RECORD_VALIDATE_OPERAND_MIN_COUNT(min_count);\ + TYPE_RECORD_VALIDATE_OPERAND_MAX_COUNT(max_count); } while (false)
Do we really need these to be macros? It seems like the only reason these aren't regular functions is the usage of WARN, and I'm inclined to say we should be using something built on top of vkd3d_shader_verror()/vkd3d_shader_vwarning() anyway, much like e.g. hlsl_error() and hlsl_warning(). Not just here, of course.
I do want to resolve error reporting/handling sooner rather than later. While to some extent that's something that can be tweaked later case-by-case, it's also something that both impacts the basic structure of the parser, and something that's generally settled for the other vkd3d-shader parsers.