summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-04-13 16:40:36 -0700
committerGitHub <noreply@github.com>2023-04-13 16:40:36 -0700
commit3bbac5f16e9dd47acd2132c0bb2a43393831c450 (patch)
treebddf137c252c164f7cd08f1f58b559b96ee49419 /source/slang/slang-check-decl.cpp
parent3b4a50d74059a26af2ed8c37fb2042f33ba7cf2c (diff)
Warn on float-to-double coercion for arguments. (#2802)
* Warn on float-to-double coercion for arguments. * Fix test. * Rename. * Fixup. --------- 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.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 63c7d9741..9b94ba492 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -1191,7 +1191,7 @@ namespace Slang
if (auto initExpr = varDecl->initExpr)
{
initExpr = CheckTerm(initExpr);
- initExpr = coerce(varDecl->type.Ptr(), initExpr);
+ initExpr = coerce(CoercionSite::Initializer, varDecl->type.Ptr(), initExpr);
varDecl->initExpr = initExpr;
maybeInferArraySizeForVariable(varDecl);
@@ -1355,7 +1355,7 @@ namespace Slang
// it to the type of the variable.
//
initExpr = CheckTerm(initExpr);
- initExpr = coerce(varDecl->type.Ptr(), initExpr);
+ initExpr = coerce(CoercionSite::Initializer, varDecl->type.Ptr(), initExpr);
varDecl->initExpr = initExpr;
// We need to ensure that any variable doesn't introduce
@@ -2860,7 +2860,7 @@ namespace Slang
// so we also need to coerce the result of the call to
// the expected type.
//
- auto coercedCall = subVisitor.coerce(resultType, checkedCall);
+ auto coercedCall = subVisitor.coerce(CoercionSite::Return, resultType, checkedCall);
// If our overload resolution or type coercion failed,
// then we have not been able to synthesize a witness
@@ -3182,7 +3182,7 @@ namespace Slang
// which involves coercing the member access `this.name` to
// the expected type of the property.
//
- auto coercedMemberRef = subVisitor.coerce(propertyType, synMemberRef);
+ auto coercedMemberRef = subVisitor.coerce(CoercionSite::Return, propertyType, synMemberRef);
auto synReturn = m_astBuilder->create<ReturnStmt>();
synReturn->expression = coercedMemberRef;
@@ -4684,7 +4684,7 @@ namespace Slang
if(auto initExpr = decl->tagExpr)
{
initExpr = CheckTerm(initExpr);
- initExpr = coerce(tagType, initExpr);
+ initExpr = coerce(CoercionSite::General, tagType, initExpr);
// We want to enforce that this is an integer constant
// expression, but we don't actually care to retain
@@ -5551,7 +5551,7 @@ namespace Slang
// actual type of the parameter.
//
initExpr = CheckTerm(initExpr);
- initExpr = coerce(typeExpr.type, initExpr);
+ initExpr = coerce(CoercionSite::Initializer, typeExpr.type, initExpr);
paramDecl->initExpr = initExpr;
// TODO: a default argument expression needs to