diff options
| author | Yong He <yonghe@outlook.com> | 2023-09-03 12:56:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-03 12:56:31 -0700 |
| commit | 1d4b5b6fd2433a10cc7ab87626cb560f54b0acbb (patch) | |
| tree | 6196d519190720fd2968ac7d4b373e3c967d5fe6 /source/slang/slang-check-expr.cpp | |
| parent | 355bb4287861f96082751042f4e58ff3598b4e5e (diff) | |
Proper lowering of functiosn that returns NonCopyable values. (#3179)
* Proper lowering of functiosn that returns NonCopyable values.
* Fix tests.
* Fix clang errors.
* Fix.
* Fix clang error.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
| -rw-r--r-- | source/slang/slang-check-expr.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index a00b1bea2..055364d5e 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -3769,6 +3769,32 @@ namespace Slang return CreateErrorExpr(expr); } + Expr* SemanticsExprVisitor::visitReturnValExpr(ReturnValExpr* expr) + { + auto scope = expr->scope; + if (scope) + { + auto parentFunc = as<CallableDecl>(getParentFunc(scope->containerDecl)); + if (parentFunc) + { + if (as<ErrorType>(parentFunc->returnType.type)) + { + expr->type = parentFunc->returnType.type; + return expr; + } + if (isNonCopyableType(parentFunc->returnType.type)) + { + expr->type.isLeftValue = true; + expr->type.type = parentFunc->returnType.type; + return expr; + } + } + } + getSink()->diagnose(expr, Diagnostics::returnValNotAvailable); + expr->type = getASTBuilder()->getErrorType(); + return expr; + } + Expr* SemanticsExprVisitor::visitAndTypeExpr(AndTypeExpr* expr) { // The left and right sides of an `&` for types must both be types. |
