From 3bbac5f16e9dd47acd2132c0bb2a43393831c450 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 13 Apr 2023 16:40:36 -0700 Subject: 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 --- source/slang/slang-check-decl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-check-decl.cpp') 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(); 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 -- cgit v1.2.3