Skip to content

Commit 43e3933

Browse files
committed
Removed deprecated AI_SET_PTR()s
1 parent 5e8bb51 commit 43e3933

File tree

7 files changed

+260
-314
lines changed

7 files changed

+260
-314
lines changed

Zend/tests/closure_018.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ var_dump($y, $x);
2222

2323
?>
2424
--EXPECT--
25+
Notice: Only variable references should be returned by reference in %sclosure_018.php on line 7
2526
int(4)
27+
28+
Notice: Only variable references should be returned by reference in %sclosure_018.php on line 7
2629
int(16)
2730
int(16)
2831
int(16)

Zend/tests/closure_019.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ test();
2020

2121
?>
2222
--EXPECTF--
23+
24+
Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
2325
int(9)
26+
27+
Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
2428
int(81)
2529

2630
Fatal error: Cannot pass parameter 1 by reference in %s on line %d

Zend/zend_compile.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2717,7 +2717,9 @@ void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC) /* {{{ */
27172717
if (expr) {
27182718
SET_NODE(opline->op1, expr);
27192719

2720-
if (do_end_vparse && zend_is_function_or_method_call(expr)) {
2720+
if (!do_end_vparse) {
2721+
opline->extended_value = ZEND_RETURNS_VALUE;
2722+
} else if (zend_is_function_or_method_call(expr)) {
27212723
opline->extended_value = ZEND_RETURNS_FUNCTION;
27222724
}
27232725
} else {

Zend/zend_compile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ int zend_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC);
840840

841841
#define ZEND_RETURNS_FUNCTION 1<<0
842842
#define ZEND_RETURNS_NEW 1<<1
843+
#define ZEND_RETURNS_VALUE 1<<2
843844

844845
#define ZEND_FAST_RET_TO_CATCH 1
845846
#define ZEND_FAST_RET_TO_FINALLY 2

Zend/zend_execute.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,14 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC)
102102
#define PZVAL_LOCK(z) Z_ADDREF_P((z))
103103
#define SELECTIVE_PZVAL_LOCK(pzv, opline) if (RETURN_VALUE_USED(opline)) { PZVAL_LOCK(pzv); }
104104

105-
#define EXTRACT_ZVAL_PTR(t) do { \
106-
temp_variable *__t = (t); \
107-
if (__t->var.ptr_ptr) { \
108-
__t->var.ptr = *__t->var.ptr_ptr; \
109-
__t->var.ptr_ptr = &__t->var.ptr; \
110-
if (!PZVAL_IS_REF(__t->var.ptr) && \
111-
Z_REFCOUNT_P(__t->var.ptr) > 2) { \
112-
SEPARATE_ZVAL(__t->var.ptr_ptr); \
113-
} \
114-
} \
105+
#define EXTRACT_ZVAL_PTR(t) do { \
106+
temp_variable *__t = (t); \
107+
__t->var.ptr = *__t->var.ptr_ptr; \
108+
__t->var.ptr_ptr = &__t->var.ptr; \
109+
if (!PZVAL_IS_REF(__t->var.ptr) && \
110+
Z_REFCOUNT_P(__t->var.ptr) > 2) { \
111+
SEPARATE_ZVAL(__t->var.ptr_ptr); \
112+
} \
115113
} while (0)
116114

117115
#define AI_SET_PTR(t, val) do { \
@@ -1215,12 +1213,12 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container
12151213
zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no effect", ce->name);
12161214
}
12171215
}
1218-
retval = &overloaded_result;
1216+
AI_SET_PTR(result, overloaded_result);
1217+
PZVAL_LOCK(overloaded_result);
12191218
} else {
1220-
retval = &EG(error_zval_ptr);
1219+
result->var.ptr_ptr = &EG(error_zval_ptr);
1220+
PZVAL_LOCK(EG(error_zval_ptr));
12211221
}
1222-
AI_SET_PTR(result, *retval);
1223-
PZVAL_LOCK(*retval);
12241222
if (dim_type == IS_TMP_VAR) {
12251223
zval_ptr_dtor(&dim);
12261224
}
@@ -1237,8 +1235,8 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container
12371235
default:
12381236
if (type == BP_VAR_UNSET) {
12391237
zend_error(E_WARNING, "Cannot unset offset in a non-array variable");
1240-
AI_SET_PTR(result, &EG(uninitialized_zval));
1241-
PZVAL_LOCK(&EG(uninitialized_zval));
1238+
result->var.ptr_ptr = &EG(uninitialized_zval_ptr);
1239+
PZVAL_LOCK(EG(uninitialized_zval_ptr));
12421240
} else {
12431241
zend_error(E_WARNING, "Cannot use a scalar value as an array");
12441242
result->var.ptr_ptr = &EG(error_zval_ptr);
@@ -1256,12 +1254,12 @@ static void zend_fetch_dimension_address_read(temp_variable *result, zval *conta
12561254

12571255
case IS_ARRAY:
12581256
retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type TSRMLS_CC);
1259-
AI_SET_PTR(result, *retval);
1257+
result->var.ptr = *retval;
12601258
PZVAL_LOCK(*retval);
12611259
return;
12621260

12631261
case IS_NULL:
1264-
AI_SET_PTR(result, &EG(uninitialized_zval));
1262+
result->var.ptr = &EG(uninitialized_zval);
12651263
PZVAL_LOCK(&EG(uninitialized_zval));
12661264
return;
12671265

@@ -1314,7 +1312,7 @@ static void zend_fetch_dimension_address_read(temp_variable *result, zval *conta
13141312
Z_STRVAL_P(ptr)[1] = 0;
13151313
Z_STRLEN_P(ptr) = 1;
13161314
}
1317-
AI_SET_PTR(result, ptr);
1315+
result->var.ptr = ptr;
13181316
return;
13191317
}
13201318
break;
@@ -1332,12 +1330,14 @@ static void zend_fetch_dimension_address_read(temp_variable *result, zval *conta
13321330
}
13331331
overloaded_result = Z_OBJ_HT_P(container)->read_dimension(container, dim, type TSRMLS_CC);
13341332

1335-
if (overloaded_result) {
1336-
AI_SET_PTR(result, overloaded_result);
1337-
PZVAL_LOCK(overloaded_result);
1338-
} else if (result) {
1339-
AI_SET_PTR(result, &EG(uninitialized_zval));
1340-
PZVAL_LOCK(&EG(uninitialized_zval));
1333+
if (result) {
1334+
if (overloaded_result) {
1335+
result->var.ptr = overloaded_result;
1336+
PZVAL_LOCK(overloaded_result);
1337+
} else {
1338+
result->var.ptr = &EG(uninitialized_zval);
1339+
PZVAL_LOCK(&EG(uninitialized_zval));
1340+
}
13411341
}
13421342
if (dim_type == IS_TMP_VAR) {
13431343
zval_ptr_dtor(&dim);
@@ -1346,7 +1346,7 @@ static void zend_fetch_dimension_address_read(temp_variable *result, zval *conta
13461346
return;
13471347

13481348
default:
1349-
AI_SET_PTR(result, &EG(uninitialized_zval));
1349+
result->var.ptr = &EG(uninitialized_zval);
13501350
PZVAL_LOCK(&EG(uninitialized_zval));
13511351
return;
13521352
}

0 commit comments

Comments
 (0)