diff options
author | Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> | 2020-03-31 07:06:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 10:06:29 -0400 |
commit | c37c94929bf575f44256469855eaa5aab411f14f (patch) | |
tree | 1e1486f455801f1797e9577ed1a6cc2d16dc6d41 /source/val/validate_decorations.cpp | |
parent | fd773eb50d628c1981338addc093df879757c2cf (diff) | |
download | SPIRV-Tools-c37c94929bf575f44256469855eaa5aab411f14f.tar.gz |
Validate Buffer and BufferBlock apply only to struct types (#3259)
Diffstat (limited to 'source/val/validate_decorations.cpp')
-rw-r--r-- | source/val/validate_decorations.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/val/validate_decorations.cpp b/source/val/validate_decorations.cpp index 3b448333..ce09e180 100644 --- a/source/val/validate_decorations.cpp +++ b/source/val/validate_decorations.cpp @@ -1524,6 +1524,22 @@ spv_result_t CheckComponentDecoration(ValidationState_t& vstate, return SPV_SUCCESS; } +// Returns SPV_SUCCESS if validation rules are satisfied for the Block +// decoration. Otherwise emits a diagnostic and returns something other than +// SPV_SUCCESS. +spv_result_t CheckBlockDecoration(ValidationState_t& vstate, + const Instruction& inst, + const Decoration& decoration) { + assert(inst.id() && "Parser ensures the target of the decoration has an ID"); + if (inst.opcode() != SpvOpTypeStruct) { + const char* const dec_name = + decoration.dec_type() == SpvDecorationBlock ? "Block" : "BufferBlock"; + return vstate.diag(SPV_ERROR_INVALID_ID, &inst) + << dec_name << " decoration on a non-struct type."; + } + return SPV_SUCCESS; +} + #define PASS_OR_BAIL_AT_LINE(X, LINE) \ { \ spv_result_t e##LINE = (X); \ @@ -1570,6 +1586,10 @@ spv_result_t CheckDecorationsFromDecoration(ValidationState_t& vstate) { case SpvDecorationNoUnsignedWrap: PASS_OR_BAIL(CheckIntegerWrapDecoration(vstate, *inst, decoration)); break; + case SpvDecorationBlock: + case SpvDecorationBufferBlock: + PASS_OR_BAIL(CheckBlockDecoration(vstate, *inst, decoration)); + break; default: break; } |