Validate that SpecId decoration target is a OpSpecConstant instruction
on a scalar
Fixes: https://github.com/KhronosGroup/SPIRV-Tools/issues/275
diff --git a/source/opcode.cpp b/source/opcode.cpp
index d0f1ef1..9f51b95 100644
--- a/source/opcode.cpp
+++ b/source/opcode.cpp
@@ -207,6 +207,17 @@
return opcode == SpvOpUndef || spvOpcodeIsConstant(opcode);
}
+bool spvOpcodeIsScalarSpecConstant(const SpvOp opcode) {
+ switch (opcode) {
+ case SpvOpSpecConstantTrue:
+ case SpvOpSpecConstantFalse:
+ case SpvOpSpecConstant:
+ return true;
+ default:
+ return false;
+ }
+}
+
int32_t spvOpcodeIsComposite(const SpvOp opcode) {
switch (opcode) {
case SpvOpTypeVector: