mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +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.
|
- Usage of @noreturn macro is type-checked as if it returns #1913.
|
||||||
- Bug when indexing into a constant array at compile time.
|
- Bug when indexing into a constant array at compile time.
|
||||||
- Fixing various issues around shifts, like `z <<= { 1, 2 }`.
|
- 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
|
### Stdlib changes
|
||||||
- Added '%h' and '%H' for printing out binary data in hexadecimal using the formatter.
|
- 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 *outer = expr;
|
||||||
expr = sema_dive_into_expression(expr);
|
expr = sema_dive_into_expression(expr);
|
||||||
|
bool allow_pointer = false;
|
||||||
// We only want && and &
|
// We only want && and &
|
||||||
if (expr->expr_kind == EXPR_SUBSCRIPT_ADDR)
|
if (expr->expr_kind == EXPR_SUBSCRIPT_ADDR)
|
||||||
{
|
{
|
||||||
expr = exprptr(expr->subscript_expr.expr);
|
expr = exprptr(expr->subscript_expr.expr);
|
||||||
|
allow_pointer = true;
|
||||||
goto CHECK_ACCESS;
|
goto CHECK_ACCESS;
|
||||||
}
|
}
|
||||||
if (expr->expr_kind != EXPR_UNARY) return true;
|
if (expr->expr_kind != EXPR_UNARY) return true;
|
||||||
@@ -598,7 +600,8 @@ CHECK_ACCESS:
|
|||||||
case TYPE_POINTER:
|
case TYPE_POINTER:
|
||||||
case TYPE_SLICE:
|
case TYPE_SLICE:
|
||||||
// &foo[2] is fine if foo is a pointer or slice.
|
// &foo[2] is fine if foo is a pointer or slice.
|
||||||
return true;
|
if (allow_pointer) return true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user