summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-12-10 03:49:25 -0800
committerGitHub <noreply@github.com>2024-12-10 19:49:25 +0800
commitb0dfb1aef2cd5483f59b858c8921707174ffdf2d (patch)
treeea6fad9c0cfbbb4348c86917e57bd25bac6c0e42 /source/slang/slang-check-decl.cpp
parent945d8dd3c4cea58f3d9f36e8fa123137f64e180e (diff)
Don't emit a warning when implicit casting from known in-range int lit to half. (#5814)
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index eeb75e3fd..a666d9df3 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -7421,6 +7421,15 @@ bool SemanticsVisitor::isScalarIntegerType(Type* type)
return isIntegerBaseType(baseType) || baseType == BaseType::Bool;
}
+bool SemanticsVisitor::isHalfType(Type* type)
+{
+ auto basicType = as<BasicExpressionType>(type);
+ if (!basicType)
+ return false;
+ auto baseType = basicType->getBaseType();
+ return baseType == BaseType::Half;
+}
+
bool SemanticsVisitor::isValidCompileTimeConstantType(Type* type)
{
return isScalarIntegerType(type) || isEnumType(type);
@@ -7466,6 +7475,9 @@ bool SemanticsVisitor::isIntValueInRangeOfType(IntegerLiteralValue value, Type*
#endif
return value >= std::numeric_limits<int64_t>::min() &&
value <= std::numeric_limits<int64_t>::max();
+
+ case BaseType::Half:
+ return value >= -2048 && value <= 2048;
default:
return false;
}