summaryrefslogtreecommitdiffstats
path: root/source/slang/check.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/check.cpp')
-rw-r--r--source/slang/check.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp
index 998324612..37c0d5baf 100644
--- a/source/slang/check.cpp
+++ b/source/slang/check.cpp
@@ -2603,10 +2603,24 @@ namespace Slang
}
else if (auto bindingAttr = as<GLSLBindingAttribute>(attr))
{
- SLANG_ASSERT(attr->args.Count() == 2);
+ // This must be vk::binding or gl::binding (as specified in core.meta.slang under vk_binding/gl_binding)
+ // Must have 2 int parameters. Ideally this would all be checked from the specification
+ // in core.meta.slang, but that's not completely implemented. So for now we check here.
+ if (attr->args.Count() != 2)
+ {
+ return false;
+ }
+
+ // TODO(JS): Prior validation currently doesn't ensure both args are ints (as specified in core.meta.slang), so check here
+ // to make sure they both are
auto binding = checkConstantIntVal(attr->args[0]);
auto set = checkConstantIntVal(attr->args[1]);
+ if (binding == nullptr || set == nullptr)
+ {
+ return false;
+ }
+
bindingAttr->binding = int32_t(binding->value);
bindingAttr->set = int32_t(set->value);
}
@@ -2703,6 +2717,13 @@ namespace Slang
return false;
}
}
+ else if (auto unrollAttr = as<UnrollAttribute>(attr))
+ {
+ // Check has an argument. We need this because default behavior is to give an error
+ // if an attribute has arguments, but not handled explicitly (and the default param will come through
+ // as 1 arg if nothing is specified)
+ SLANG_ASSERT(attr->args.Count() == 1);
+ }
else if (auto userDefAttr = as<UserDefinedAttribute>(attr))
{
// check arguments against attribute parameters defined in attribClassDecl
@@ -2813,7 +2834,6 @@ namespace Slang
{
// TODO: support checking the argument against the declared
// type for the parameter.
-
}
else
{
@@ -2826,6 +2846,9 @@ namespace Slang
//
// TODO: we need to figure out how to hook up
// default arguments as needed.
+ // For now just copy the expression over.
+
+ attr->args.Add(paramDecl->initExpr);
}
else
{