forked from microsoft/DirectXShaderCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nullptr checks to handle undefined arrays (microsoft#5872)
When a variable declaration is not found, an error is emitted, and a null value returned. Not all function know what to do with that null value. I fix this by adding a few extra nullptr checks so that the compiler can unwind the stack and return gracefully. Fixes [SPIR-V] `-Wundefined-internal` SIGSEGVs the compiler when `-spirv` output microsoft#5821
- Loading branch information
Showing
3 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tools/clang/test/CodeGenSPIRV_Lit/undefined.static.template.member.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// RUN: not %dxc -T ps_6_7 -E main -fcgl %s -spirv 2>&1 | FileCheck %s | ||
|
||
template<uint32_t N, typename T=double> | ||
struct GaussLegendreValues | ||
{ | ||
const static T wi[N]; | ||
}; | ||
|
||
static int test_value = 1567; | ||
|
||
float main() : SV_Target | ||
{ | ||
return float(GaussLegendreValues<2>::wi[test_value]); | ||
} | ||
|
||
// CHECK: :6:20: warning: variable 'GaussLegendreValues<2, double>::wi' has internal linkage but is not defined [-Wundefined-internal] | ||
// CHECK-NEXT: const static T wi[N]; | ||
// CHECK: :13:42: note: used here | ||
// CHECK-NEXT: return float(GaussLegendreValues<2>::wi[test_value]); | ||
// CHECK: :6:20: fatal error: found unregistered decl | ||
// CHECK-NEXT: const static T wi[N]; |