@@ -764,6 +764,90 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
764
764
ASSERT_TRUE (Consumer->isSatisfied ());
765
765
}
766
766
767
+ TEST_F (ParseHLSLRootSignatureTest, InvalidLexOverflowedFloatTest) {
768
+ // This test will check that the lexing fails due to a float overflow
769
+ const llvm::StringLiteral Source = R"cc(
770
+ StaticSampler(s0, mipLODBias = 3.402823467e+38F)
771
+ )cc" ;
772
+
773
+ TrivialModuleLoader ModLoader;
774
+ auto PP = createPP (Source, ModLoader);
775
+ auto TokLoc = SourceLocation ();
776
+
777
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
778
+ SmallVector<RootElement> Elements;
779
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
780
+
781
+ // Test correct diagnostic produced
782
+ Consumer->setExpected (diag::err_hlsl_number_literal_overflow);
783
+ ASSERT_TRUE (Parser.parse ());
784
+
785
+ ASSERT_TRUE (Consumer->isSatisfied ());
786
+ }
787
+
788
+ TEST_F (ParseHLSLRootSignatureTest, InvalidLexNegOverflowedFloatTest) {
789
+ // This test will check that the lexing fails due to negative float overflow
790
+ const llvm::StringLiteral Source = R"cc(
791
+ StaticSampler(s0, mipLODBias = -3.402823467e+38F)
792
+ )cc" ;
793
+
794
+ TrivialModuleLoader ModLoader;
795
+ auto PP = createPP (Source, ModLoader);
796
+ auto TokLoc = SourceLocation ();
797
+
798
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
799
+ SmallVector<RootElement> Elements;
800
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
801
+
802
+ // Test correct diagnostic produced
803
+ Consumer->setExpected (diag::err_hlsl_number_literal_overflow);
804
+ ASSERT_TRUE (Parser.parse ());
805
+
806
+ ASSERT_TRUE (Consumer->isSatisfied ());
807
+ }
808
+
809
+ TEST_F (ParseHLSLRootSignatureTest, InvalidLexOverflowedDoubleTest) {
810
+ // This test will check that the lexing fails due to an overflow of double
811
+ const llvm::StringLiteral Source = R"cc(
812
+ StaticSampler(s0, mipLODBias = 1.e+500)
813
+ )cc" ;
814
+
815
+ TrivialModuleLoader ModLoader;
816
+ auto PP = createPP (Source, ModLoader);
817
+ auto TokLoc = SourceLocation ();
818
+
819
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
820
+ SmallVector<RootElement> Elements;
821
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
822
+
823
+ // Test correct diagnostic produced
824
+ Consumer->setExpected (diag::err_hlsl_number_literal_overflow);
825
+ ASSERT_TRUE (Parser.parse ());
826
+
827
+ ASSERT_TRUE (Consumer->isSatisfied ());
828
+ }
829
+
830
+ TEST_F (ParseHLSLRootSignatureTest, InvalidLexUnderflowFloatTest) {
831
+ // This test will check that the lexing fails due to double underflow
832
+ const llvm::StringLiteral Source = R"cc(
833
+ StaticSampler(s0, mipLODBias = 10e-309)
834
+ )cc" ;
835
+
836
+ TrivialModuleLoader ModLoader;
837
+ auto PP = createPP (Source, ModLoader);
838
+ auto TokLoc = SourceLocation ();
839
+
840
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
841
+ SmallVector<RootElement> Elements;
842
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
843
+
844
+ // Test correct diagnostic produced
845
+ Consumer->setExpected (diag::err_hlsl_number_literal_underflow);
846
+ ASSERT_TRUE (Parser.parse ());
847
+
848
+ ASSERT_TRUE (Consumer->isSatisfied ());
849
+ }
850
+
767
851
TEST_F (ParseHLSLRootSignatureTest, InvalidNonZeroFlagsTest) {
768
852
// This test will check that parsing fails when a non-zero integer literal
769
853
// is given to flags
0 commit comments