summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-09-15 14:22:59 -0700
committerGitHub <noreply@github.com>2022-09-15 14:22:59 -0700
commita6032446c6bf7f64d1e201bf438a4c7605a3dbb4 (patch)
treea95267c52155e13699ff9aab38ab68353d76939e /source/slang/slang-check-decl.cpp
parent05f9aaf6a4ef246dcf89b00000a8e59e90c47662 (diff)
Language feature: pointer sized int types. (#2401)
* Language feature: pointer sized int types. * Fix. * small change to test. * Fix stdlib. * Fix. * Fix. * Add typedef for `size_t` in stdlib. * Fix test. * Add `intptr_t::size` constant. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 125f0cb08..660e28802 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -1096,10 +1096,12 @@ namespace Slang
case BaseType::Int16:
case BaseType::Int:
case BaseType::Int64:
+ case BaseType::IntPtr:
case BaseType::UInt8:
case BaseType::UInt16:
case BaseType::UInt:
case BaseType::UInt64:
+ case BaseType::UIntPtr:
break;
default:
getSink()->diagnose(varDecl, Diagnostics::staticConstRequirementMustBeIntOrBool);
@@ -3620,16 +3622,28 @@ namespace Slang
case BaseType::UInt16:
return (value >= 0 && value <= std::numeric_limits<uint16_t>::max()) || (value == -1);
case BaseType::UInt:
+#if SLANG_PTR_IS_32
+ case BaseType::UIntPtr:
+#endif
return (value >= 0 && value <= std::numeric_limits<uint32_t>::max()) || (value == -1);
case BaseType::UInt64:
+#if SLANG_PTR_IS_64
+ case BaseType::UIntPtr:
+#endif
return true;
case BaseType::Int8:
return value >= std::numeric_limits<int8_t>::min() && value <= std::numeric_limits<int8_t>::max();
case BaseType::Int16:
return value >= std::numeric_limits<int16_t>::min() && value <= std::numeric_limits<int16_t>::max();
case BaseType::Int:
+#if SLANG_PTR_IS_32
+ case BaseType::IntPtr:
+#endif
return value >= std::numeric_limits<int32_t>::min() && value <= std::numeric_limits<int32_t>::max();
case BaseType::Int64:
+#if SLANG_PTR_IS_64
+ case BaseType::IntPtr:
+#endif
return value >= std::numeric_limits<int64_t>::min() && value <= std::numeric_limits<int64_t>::max();
default:
return false;