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.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp
index e06578c86..b1df71428 100644
--- a/source/slang/check.cpp
+++ b/source/slang/check.cpp
@@ -1530,6 +1530,8 @@ namespace Slang
SLANG_ASSERT(attr->args.Count() == 1);
auto val = checkConstantIntVal(attr->args[0]);
+ if(!val) return false;
+
maxVertexCountAttr->value = (int32_t)val->value;
}
else if(auto instanceAttr = attr.As<InstanceAttribute>())
@@ -1537,6 +1539,8 @@ namespace Slang
SLANG_ASSERT(attr->args.Count() == 1);
auto val = checkConstantIntVal(attr->args[0]);
+ if(!val) return false;
+
instanceAttr->value = (int32_t)val->value;
}
else if(auto entryPointAttr = attr.As<EntryPointAttribute>())
@@ -3555,8 +3559,15 @@ namespace Slang
// Enforce that an expression resolves to an integer constant, and get its value
RefPtr<IntVal> CheckIntegerConstantExpression(Expr* inExpr)
{
+ // No need to issue further errors if the expression didn't even type-check.
+ if(IsErrorExpr(inExpr)) return nullptr;
+
// First coerce the expression to the expected type
auto expr = Coerce(getSession()->getIntType(),inExpr);
+
+ // No need to issue further errors if the type coercion failed.
+ if(IsErrorExpr(expr)) return nullptr;
+
auto result = TryCheckIntegerConstantExpression(expr.Ptr());
if (!result)
{