summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-type.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-08-17 23:08:34 -0700
committerGitHub <noreply@github.com>2022-08-17 23:08:34 -0700
commitadaea0e993fd8db351b5dad92802e47ed6d0ec77 (patch)
treedfad5201677b0202b0b890cbae066b5b2f3f033b /source/slang/slang-check-type.cpp
parentd65c6183c0d8b365aa182c3d9026ba85522531f2 (diff)
Warning on lossy implicit casts. (#2367)
* Warning on bool to float conversion. * Fix test cases. * Improve. * LanguageServer: don't show constant value for non constant variables. * Fix tests. * Fix warnings in tests. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-type.cpp')
-rw-r--r--source/slang/slang-check-type.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/source/slang/slang-check-type.cpp b/source/slang/slang-check-type.cpp
index 50bc55641..b8789dd76 100644
--- a/source/slang/slang-check-type.cpp
+++ b/source/slang/slang-check-type.cpp
@@ -119,9 +119,14 @@ namespace Slang
return ExpectAType(exp);
}
- IntVal* SemanticsVisitor::ExtractGenericArgInteger(Expr* exp, DiagnosticSink* sink)
+ IntVal* SemanticsVisitor::ExtractGenericArgInteger(Expr* exp, Type* genericParamType, DiagnosticSink* sink)
{
- IntVal* val = CheckIntegerConstantExpression(exp, sink);
+ IntVal* val = CheckIntegerConstantExpression(
+ exp,
+ genericParamType ? IntegerConstantExpressionCoercionType::SpecificType
+ : IntegerConstantExpressionCoercionType::AnyInteger,
+ genericParamType,
+ sink);
if(val) return val;
// If the argument expression could not be coerced to an integer
@@ -132,9 +137,9 @@ namespace Slang
return val;
}
- IntVal* SemanticsVisitor::ExtractGenericArgInteger(Expr* exp)
+ IntVal* SemanticsVisitor::ExtractGenericArgInteger(Expr* exp, Type* genericParamType)
{
- return ExtractGenericArgInteger(exp, getSink());
+ return ExtractGenericArgInteger(exp, genericParamType, getSink());
}
Val* SemanticsVisitor::ExtractGenericArgVal(Expr* exp)
@@ -158,7 +163,7 @@ namespace Slang
{
CheckExpr(exp);
}
- return ExtractGenericArgInteger(exp);
+ return ExtractGenericArgInteger(exp, nullptr);
}
}
@@ -275,7 +280,6 @@ namespace Slang
}
return false;
}
-
// TODO: this is one place where syntax should get cloned!
if (outProperType)
args.add(valParam->initExpr);