@@ -793,6 +793,90 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
793
793
ASSERT_TRUE (Consumer->isSatisfied ());
794
794
}
795
795
796
+ TEST_F (ParseHLSLRootSignatureTest, InvalidLexOverflowedFloatTest) {
797
+ // This test will check that the lexing fails due to a float overflow
798
+ const llvm::StringLiteral Source = R"cc(
799
+ StaticSampler(s0, mipLODBias = 3.402823467e+38F)
800
+ )cc" ;
801
+
802
+ TrivialModuleLoader ModLoader;
803
+ auto PP = createPP (Source, ModLoader);
804
+ auto TokLoc = SourceLocation ();
805
+
806
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
807
+ SmallVector<RootElement> Elements;
808
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
809
+
810
+ // Test correct diagnostic produced
811
+ Consumer->setExpected (diag::err_hlsl_number_literal_overflow);
812
+ ASSERT_TRUE (Parser.parse ());
813
+
814
+ ASSERT_TRUE (Consumer->isSatisfied ());
815
+ }
816
+
817
+ TEST_F (ParseHLSLRootSignatureTest, InvalidLexNegOverflowedFloatTest) {
818
+ // This test will check that the lexing fails due to negative float overflow
819
+ const llvm::StringLiteral Source = R"cc(
820
+ StaticSampler(s0, mipLODBias = -3.402823467e+38F)
821
+ )cc" ;
822
+
823
+ TrivialModuleLoader ModLoader;
824
+ auto PP = createPP (Source, ModLoader);
825
+ auto TokLoc = SourceLocation ();
826
+
827
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
828
+ SmallVector<RootElement> Elements;
829
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
830
+
831
+ // Test correct diagnostic produced
832
+ Consumer->setExpected (diag::err_hlsl_number_literal_overflow);
833
+ ASSERT_TRUE (Parser.parse ());
834
+
835
+ ASSERT_TRUE (Consumer->isSatisfied ());
836
+ }
837
+
838
+ TEST_F (ParseHLSLRootSignatureTest, InvalidLexOverflowedDoubleTest) {
839
+ // This test will check that the lexing fails due to an overflow of double
840
+ const llvm::StringLiteral Source = R"cc(
841
+ StaticSampler(s0, mipLODBias = 1.e+500)
842
+ )cc" ;
843
+
844
+ TrivialModuleLoader ModLoader;
845
+ auto PP = createPP (Source, ModLoader);
846
+ auto TokLoc = SourceLocation ();
847
+
848
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
849
+ SmallVector<RootElement> Elements;
850
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
851
+
852
+ // Test correct diagnostic produced
853
+ Consumer->setExpected (diag::err_hlsl_number_literal_overflow);
854
+ ASSERT_TRUE (Parser.parse ());
855
+
856
+ ASSERT_TRUE (Consumer->isSatisfied ());
857
+ }
858
+
859
+ TEST_F (ParseHLSLRootSignatureTest, InvalidLexUnderflowFloatTest) {
860
+ // This test will check that the lexing fails due to double underflow
861
+ const llvm::StringLiteral Source = R"cc(
862
+ StaticSampler(s0, mipLODBias = 10e-309)
863
+ )cc" ;
864
+
865
+ TrivialModuleLoader ModLoader;
866
+ auto PP = createPP (Source, ModLoader);
867
+ auto TokLoc = SourceLocation ();
868
+
869
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
870
+ SmallVector<RootElement> Elements;
871
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
872
+
873
+ // Test correct diagnostic produced
874
+ Consumer->setExpected (diag::err_hlsl_number_literal_underflow);
875
+ ASSERT_TRUE (Parser.parse ());
876
+
877
+ ASSERT_TRUE (Consumer->isSatisfied ());
878
+ }
879
+
796
880
TEST_F (ParseHLSLRootSignatureTest, InvalidNonZeroFlagsTest) {
797
881
// This test will check that parsing fails when a non-zero integer literal
798
882
// is given to flags
0 commit comments