@@ -655,7 +655,7 @@ TEST_F(ValidateConstant, ConstantCompositeReplicateNotConstant) {
655655 EXPECT_EQ (SPV_ERROR_INVALID_ID , ValidateInstructions ());
656656 EXPECT_THAT (getDiagnosticString (),
657657 HasSubstr (" OpConstantCompositeReplicateEXT must only have "
658- " constant or undef operands: <id>" ));
658+ " constant, undef, or poison operands: <id>" ));
659659}
660660
661661TEST_F (ValidateConstant, ConstantCompositeSpecOperand) {
@@ -697,9 +697,44 @@ TEST_F(ValidateConstant, ConstantCompositeNotConstant) {
697697)" ;
698698 CompileSuccessfully (spirv);
699699 EXPECT_EQ (SPV_ERROR_INVALID_ID , ValidateInstructions ());
700- EXPECT_THAT (getDiagnosticString (),
701- HasSubstr (" OpConstantComposite must only have constant or undef "
702- " operands: <id>" ));
700+ EXPECT_THAT (
701+ getDiagnosticString (),
702+ HasSubstr (" OpConstantComposite must only have constant, undef, or "
703+ " poison operands: <id>" ));
704+ }
705+
706+ TEST_F (ValidateConstant, ConstantCompositePoisonConstituentGood) {
707+ std::string spirv =
708+ std::string (
709+ " OpCapability Shader\n OpCapability Linkage\n OpCapability "
710+ " PoisonFreezeKHR\n OpExtension \" SPV_KHR_poison_freeze\"\n "
711+ " OpMemoryModel Logical Simple\n " ) +
712+ R"(
713+ %int = OpTypeInt 32 1
714+ %int_4 = OpConstant %int 4
715+ %arr = OpTypeArray %int %int_4
716+ %poison = OpPoisonKHR %int
717+ %const_arr = OpConstantComposite %arr %poison %poison %poison %poison
718+ )" ;
719+ CompileSuccessfully (spirv);
720+ EXPECT_EQ (SPV_SUCCESS , ValidateInstructions ());
721+ }
722+
723+ TEST_F (ValidateConstant, SpecConstantCompositePoisonConstituentGood) {
724+ std::string spirv =
725+ std::string (
726+ " OpCapability Shader\n OpCapability Linkage\n OpCapability "
727+ " PoisonFreezeKHR\n OpExtension \" SPV_KHR_poison_freeze\"\n "
728+ " OpMemoryModel Logical Simple\n " ) +
729+ R"(
730+ %int = OpTypeInt 32 1
731+ %int_4 = OpConstant %int 4
732+ %arr = OpTypeArray %int %int_4
733+ %poison = OpPoisonKHR %int
734+ %const_arr = OpSpecConstantComposite %arr %poison %poison %poison %poison
735+ )" ;
736+ CompileSuccessfully (spirv);
737+ EXPECT_EQ (SPV_SUCCESS , ValidateInstructions ());
703738}
704739
705740TEST_F (ValidateConstant, ConstantCompositeReplicateNotComposite) {
0 commit comments