diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2024-04-22 10:07:06 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-22 10:07:06 -0400 |
| commit | 923ef7af304f2f118b0aee153bd50e054ebc50c9 (patch) | |
| tree | 9cb2b161bf88040fb36239d476d39b7cda8933d1 /source/slang/slang-ir-lower-reinterpret.cpp | |
| parent | c5b855d77f6cdcc1ecb5c24de98f28347700e3c8 (diff) | |
bit_cast & reinterpret warning if src->dst type not equally sized. (#3988)
* bit_cast & reinterpret warning if src->dst type not equally sized.
bit_cast & reinterpret warning if src->dst type not equally sized.
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-ir-lower-reinterpret.cpp')
| -rw-r--r-- | source/slang/slang-ir-lower-reinterpret.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/source/slang/slang-ir-lower-reinterpret.cpp b/source/slang/slang-ir-lower-reinterpret.cpp index afc710539..34d4b77d9 100644 --- a/source/slang/slang-ir-lower-reinterpret.cpp +++ b/source/slang/slang-ir-lower-reinterpret.cpp @@ -60,15 +60,23 @@ struct ReinterpretLoweringContext auto fromType = operand->getDataType(); auto toType = inst->getDataType(); SlangInt fromTypeSize = getAnyValueSize(fromType); + bool cantPack = false; if (fromTypeSize < 0) { + cantPack = true; sink->diagnose(inst->sourceLoc, Slang::Diagnostics::typeCannotBePackedIntoAnyValue, fromType); } SlangInt toTypeSize = getAnyValueSize(toType); if (toTypeSize < 0) { + cantPack = true; sink->diagnose(inst->sourceLoc, Slang::Diagnostics::typeCannotBePackedIntoAnyValue, toType); } + if (fromTypeSize != toTypeSize + && cantPack == false) + { + sink->diagnose(inst->sourceLoc, Slang::Diagnostics::notEqualReinterpretCastSize, fromType, fromTypeSize, toType, toTypeSize); + } SlangInt anyValueSize = Math::Max(fromTypeSize, toTypeSize); IRBuilder builder(module); |
