Explorar el Código

[spirv] Fix bug in handling preprocessor results. (#1857)

Ehsan hace 7 años
padre
commit
0349b1a96f

+ 8 - 0
tools/clang/test/CodeGenSPIRV/preprocess.error.hlsl

@@ -0,0 +1,8 @@
+// Run: %dxc -T cs_6_0 -E main -Zi
+
+#include "DoesntExist.hlsl"
+
+void main() {}
+
+
+// CHECK: 3:10: fatal error: 'DoesntExist.hlsl' file not found

+ 1 - 1
tools/clang/tools/dxcompiler/dxcompilerobj.cpp

@@ -368,8 +368,8 @@ public:
         IFT(ppSrcCodeResult->GetStatus(&status));
         if (SUCCEEDED(status)) {
           IFT(ppSrcCodeResult->GetResult(&ppSrcCode));
+          pSource = ppSrcCode;
         }
-        pSource = ppSrcCode;
       }
 #endif // ENABLE_SPIRV_CODEGEN
 

+ 5 - 0
tools/clang/unittests/SPIRV/CodeGenSPIRVTest.cpp

@@ -1756,4 +1756,9 @@ TEST_F(FileTest, LegalizationExample21) {
   runFileTest("legal-examples/21-combined-ok.hlsl");
 }
 
+TEST_F(FileTest, PreprocessorError) {
+  // Tests that preprocessor error is surfaced
+  runFileTest("preprocess.error.hlsl", Expect::Failure);
+}
+
 } // namespace