| 353 | } |
| 354 | |
| 355 | spv_result_t ValidateLifetime(ValidationState_t& _, const Instruction* inst) { |
| 356 | const uint32_t pointer_id = _.GetOperandTypeId(inst, 0); |
| 357 | const Instruction* pointer_inst = _.FindDef(pointer_id); |
| 358 | if (pointer_inst->opcode() != spv::Op::OpTypePointer) { |
| 359 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 360 | << "Op" << spvOpcodeString(inst->opcode()) |
| 361 | << " pointer operand type must be a OpTypePointer."; |
| 362 | } else if (pointer_inst->GetOperandAs<spv::StorageClass>(1) != |
| 363 | spv::StorageClass::Function) { |
| 364 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 365 | << "Op" << spvOpcodeString(inst->opcode()) |
| 366 | << " pointer operand must be in the Function storage class."; |
| 367 | } |
| 368 | |
| 369 | const uint32_t size = inst->GetOperandAs<uint32_t>(1); |
| 370 | if (size != 0) { |
| 371 | if (!_.HasCapability(spv::Capability::Addresses)) { |
| 372 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 373 | << "Op" << spvOpcodeString(inst->opcode()) |
| 374 | << " size is non-zero, but the Addresses Capability is not " |
| 375 | "declared."; |
| 376 | } |
| 377 | // TODO - "Size must be 0 if Pointer is a pointer to a non-void type" |
| 378 | } |
| 379 | |
| 380 | return SPV_SUCCESS; |
| 381 | } |
| 382 | |
| 383 | } // namespace |
| 384 |
no test coverage detected