diff options
author | Bob Weinand <bobwei9@hotmail.com> | 2015-07-02 20:47:44 +0200 |
---|---|---|
committer | Bob Weinand <bobwei9@hotmail.com> | 2015-07-02 20:47:44 +0200 |
commit | 94722e12cf4ba9a16f8a9f009d60b2e3f0f80e12 (patch) | |
tree | e45b829d0a7a13a4d1aedf8a4e5d17248629c908 /Zend | |
parent | b874f1a73d37f17effe7b85042fef0dc703448f8 (diff) | |
download | php-git-94722e12cf4ba9a16f8a9f009d60b2e3f0f80e12.tar.gz |
Introduce ArithmeticError
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend_exceptions.c | 7 | ||||
-rw-r--r-- | Zend/zend_exceptions.h | 1 | ||||
-rw-r--r-- | Zend/zend_operators.c | 6 |
3 files changed, 10 insertions, 4 deletions
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 9f5b2448d1..8c44b31d8c 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -31,6 +31,7 @@ #include "zend_smart_str.h" ZEND_API zend_class_entry *zend_ce_throwable; +ZEND_API zend_class_entry *zend_ce_arithmetic_error; ZEND_API zend_class_entry *zend_ce_division_by_zero_error; static zend_class_entry *default_exception_ce; @@ -855,8 +856,12 @@ void zend_register_default_exception(void) /* {{{ */ type_error_ce = zend_register_internal_class_ex(&ce, error_ce); type_error_ce->create_object = zend_default_exception_new; + INIT_CLASS_ENTRY(ce, "ArithmeticError", NULL); + zend_ce_arithmetic_error = zend_register_internal_class_ex(&ce, error_ce); + zend_ce_arithmetic_error->create_object = zend_default_exception_new; + INIT_CLASS_ENTRY(ce, "DivisionByZeroError", NULL); - zend_ce_division_by_zero_error = zend_register_internal_class_ex(&ce, error_ce); + zend_ce_division_by_zero_error = zend_register_internal_class_ex(&ce, zend_ce_arithmetic_error); zend_ce_division_by_zero_error->create_object = zend_default_exception_new; } /* }}} */ diff --git a/Zend/zend_exceptions.h b/Zend/zend_exceptions.h index f07bc78b88..8b5deed15c 100644 --- a/Zend/zend_exceptions.h +++ b/Zend/zend_exceptions.h @@ -27,6 +27,7 @@ BEGIN_EXTERN_C() extern ZEND_API zend_class_entry *zend_ce_throwable; +extern ZEND_API zend_class_entry *zend_ce_arithmetic_error; extern ZEND_API zend_class_entry *zend_ce_division_by_zero_error; ZEND_API void zend_exception_set_previous(zend_object *exception, zend_object *add_previous); diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 5ad1a14791..5e7a2911a1 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1167,7 +1167,7 @@ ZEND_API int ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* { if (EG(current_execute_data) && !CG(in_compilation)) { zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero"); } else { - zend_error_noreturn(E_ERROR, "Division by zero"); + zend_error_noreturn(E_ERROR, "Modulo by zero"); } ZVAL_UNDEF(result); return FAILURE; @@ -1518,7 +1518,7 @@ ZEND_API int ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op return SUCCESS; } else { if (EG(current_execute_data) && !CG(in_compilation)) { - zend_throw_exception_ex(NULL, 0, "Bit shift by negative number"); + zend_throw_exception_ex(zend_ce_arithmetic_error, 0, "Bit shift by negative number"); } else { zend_error_noreturn(E_ERROR, "Bit shift by negative number"); } @@ -1549,7 +1549,7 @@ ZEND_API int ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *o return SUCCESS; } else { if (EG(current_execute_data) && !CG(in_compilation)) { - zend_throw_exception_ex(NULL, 0, "Bit shift by negative number"); + zend_throw_exception_ex(zend_ce_arithmetic_error, 0, "Bit shift by negative number"); } else { zend_error_noreturn(E_ERROR, "Bit shift by negative number"); } |