mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
return (any)&foo would not be reported as an escaping variable if foo was a pointer or slice.
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
- Usage of @noreturn macro is type-checked as if it returns #1913.
|
||||
- Bug when indexing into a constant array at compile time.
|
||||
- Fixing various issues around shifts, like `z <<= { 1, 2 }`.
|
||||
- `return (any)&foo` would not be reported as an escaping variable if `foo` was a pointer or slice.
|
||||
|
||||
### Stdlib changes
|
||||
- Added '%h' and '%H' for printing out binary data in hexadecimal using the formatter.
|
||||
|
||||
@@ -569,10 +569,12 @@ INLINE bool sema_check_not_stack_variable_escape(SemaContext *context, Expr *exp
|
||||
{
|
||||
Expr *outer = expr;
|
||||
expr = sema_dive_into_expression(expr);
|
||||
bool allow_pointer = false;
|
||||
// We only want && and &
|
||||
if (expr->expr_kind == EXPR_SUBSCRIPT_ADDR)
|
||||
{
|
||||
expr = exprptr(expr->subscript_expr.expr);
|
||||
allow_pointer = true;
|
||||
goto CHECK_ACCESS;
|
||||
}
|
||||
if (expr->expr_kind != EXPR_UNARY) return true;
|
||||
@@ -598,7 +600,8 @@ CHECK_ACCESS:
|
||||
case TYPE_POINTER:
|
||||
case TYPE_SLICE:
|
||||
// &foo[2] is fine if foo is a pointer or slice.
|
||||
return true;
|
||||
if (allow_pointer) return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user