Merge branch 'PHP-7.0'

This commit is contained in:
Andrea Faulds committed 2015-12-19 02:35:19 +00:00
commit 5d0dfda60c
2 files changed
+23 -26

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
--TEST--
Bug #70804 (Unary add on negative zero produces positive zero)
--FILE--
<?php
var_dump(+(-0.0));
var_dump(+(float)"-0");
$foo = +(-sin(0));
var_dump($foo);
?>
--EXPECT--
float(-0)
float(-0)
float(-0)
+6 -26
View File
@@ -6044,16 +6044,8 @@ static inline void zend_ct_eval_unary_op(zval *result, uint32_t opcode, zval *op
static inline void zend_ct_eval_unary_pm(zval *result, zend_ast_kind kind, zval *op) /* {{{ */
{
zval left;
if (kind == ZEND_AST_UNARY_PLUS) {
ZVAL_LONG(&left, 0);
add_function(result, &left, op);
} else {
/* We use `(-1) * $a` instead of `0 - $a`, because the latter handles
* negative zero wrong.
*/
ZVAL_LONG(&left, -1);
mul_function(result, &left, op);
}
ZVAL_LONG(&left, (kind == ZEND_AST_UNARY_PLUS) ? 1 : -1);
mul_function(result, &left, op);
}
/* }}} */
@@ -6244,6 +6236,7 @@ void zend_compile_unary_pm(znode *result, zend_ast *ast) /* {{{ */
{
zend_ast *expr_ast = ast->child[0];
znode expr_node;
znode lefthand_node;
ZEND_ASSERT(ast->kind == ZEND_AST_UNARY_PLUS || ast->kind == ZEND_AST_UNARY_MINUS);
@@ -6256,22 +6249,9 @@ void zend_compile_unary_pm(znode *result, zend_ast *ast) /* {{{ */
return;
}
if (ast->kind == ZEND_AST_UNARY_PLUS) {
znode zero_node;
zero_node.op_type = IS_CONST;
ZVAL_LONG(&zero_node.u.constant, 0);
zend_emit_op_tmp(result, ZEND_ADD, &zero_node, &expr_node);
} else {
/* We use `(-1) * $a` instead of `0 - $a`, because the latter handles
* negative zero wrong.
*/
znode neg_one_node;
neg_one_node.op_type = IS_CONST;
ZVAL_LONG(&neg_one_node.u.constant, -1);
zend_emit_op_tmp(result, ZEND_MUL, &neg_one_node, &expr_node);
}
lefthand_node.op_type = IS_CONST;
ZVAL_LONG(&lefthand_node.u.constant, (ast->kind == ZEND_AST_UNARY_PLUS) ? 1 : -1);
zend_emit_op_tmp(result, ZEND_MUL, &lefthand_node, &expr_node);
}
/* }}} */