From 56c351f98eb46167154f63ec7b947c5ed73ca86c Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Mon, 16 Sep 2024 11:26:43 -0700 Subject: [PATCH] zend_compile.c: remove unneeded `const_expr_context` wrapper for boolean The struct only has a single value, whether to allow expressions with dynamic values - instead of using a struct, just pass around the boolean value. --- Zend/zend_compile.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 63787c902f647..d67821b77a16f 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -11178,14 +11178,9 @@ static void zend_compile_const_expr_args(zend_ast **ast_ptr) } } -typedef struct { - /* Whether the value of this expression may differ on each evaluation. */ - bool allow_dynamic; -} const_expr_context; - static void zend_compile_const_expr(zend_ast **ast_ptr, void *context) /* {{{ */ { - const_expr_context *ctx = (const_expr_context *) context; + bool allow_dynamic = *(bool *) context; zend_ast *ast = *ast_ptr; if (ast == NULL || ast->kind == ZEND_AST_ZVAL) { return; @@ -11209,7 +11204,7 @@ static void zend_compile_const_expr(zend_ast **ast_ptr, void *context) /* {{{ */ zend_compile_const_expr_magic_const(ast_ptr); break; case ZEND_AST_NEW: - if (!ctx->allow_dynamic) { + if (!allow_dynamic) { zend_error_noreturn(E_COMPILE_ERROR, "New expressions are not supported in this context"); } @@ -11226,11 +11221,8 @@ static void zend_compile_const_expr(zend_ast **ast_ptr, void *context) /* {{{ */ void zend_const_expr_to_zval(zval *result, zend_ast **ast_ptr, bool allow_dynamic) /* {{{ */ { - const_expr_context context; - context.allow_dynamic = allow_dynamic; - zend_eval_const_expr(ast_ptr); - zend_compile_const_expr(ast_ptr, &context); + zend_compile_const_expr(ast_ptr, &allow_dynamic); if ((*ast_ptr)->kind != ZEND_AST_ZVAL) { /* Replace with compiled AST zval representation. */ zval ast_zv;