@@ -238,6 +238,7 @@ class CompilerTest : public ::testing::Test {
238
238
TEST_METHOD (LibGVStore)
239
239
TEST_METHOD (PreprocessWhenExpandTokenPastingOperandThenAccept)
240
240
TEST_METHOD (PreprocessWithDebugOptsThenOk)
241
+ TEST_METHOD (PreprocessCheckBuiltinIsOk)
241
242
TEST_METHOD (WhenSigMismatchPCFunctionThenFail)
242
243
TEST_METHOD (CompileOtherModesWithDebugOptsThenOk)
243
244
@@ -3967,6 +3968,30 @@ TEST_F(CompilerTest, PreprocessWithDebugOptsThenOk) {
3967
3968
" int BAR;\n " , text.c_str ());
3968
3969
}
3969
3970
3971
+ // Make sure that '#line 1 "<built-in>"' won't blow up when preprocessing.
3972
+ TEST_F (CompilerTest, PreprocessCheckBuiltinIsOk) {
3973
+ CComPtr<IDxcCompiler> pCompiler;
3974
+ CComPtr<IDxcOperationResult> pResult;
3975
+ CComPtr<IDxcBlobEncoding> pSource;
3976
+
3977
+ VERIFY_SUCCEEDED (CreateCompiler (&pCompiler));
3978
+ CreateBlobFromText (
3979
+ " #line 1 \" <built-in>\"\r\n "
3980
+ " int x;" , &pSource);
3981
+ VERIFY_SUCCEEDED (pCompiler->Preprocess (pSource, L" file.hlsl" , nullptr , 0 ,
3982
+ nullptr , 0 , nullptr ,
3983
+ &pResult));
3984
+ HRESULT hrOp;
3985
+ VERIFY_SUCCEEDED (pResult->GetStatus (&hrOp));
3986
+ VERIFY_SUCCEEDED (hrOp);
3987
+
3988
+ CComPtr<IDxcBlob> pOutText;
3989
+ VERIFY_SUCCEEDED (pResult->GetResult (&pOutText));
3990
+ std::string text (BlobToUtf8 (pOutText));
3991
+ VERIFY_ARE_EQUAL_STR (
3992
+ " #line 1 \" file.hlsl\"\n\n " , text.c_str ());
3993
+ }
3994
+
3970
3995
TEST_F (CompilerTest, CompileOtherModesWithDebugOptsThenOk) {
3971
3996
// Make sure debug options, such as -Zi and -Fd,
3972
3997
// are simply ignored when compiling in modes:
0 commit comments