Zend/zend_type_code: remove hard-coded integer values and
remove unused macro ZEND_SAME_FAKE_TYPE
Zend/zend_variables: add _Static_assert on the size zend_rc_dtor_func
_Static_assert is C11, but has been supported since GCC 4.6.
Also removing the comment about keeping those values in sync with
`zend_variables.c` which was obsoleted by commit 0460420205
(designated initializers).
Closes GH-10714.
This commit is contained in:

committed by
David Carlier

parent
3db32439f9
commit
c7637ed1c0
@ -18,43 +18,48 @@
|
|||||||
#define ZEND_TYPE_CODE_H
|
#define ZEND_TYPE_CODE_H
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/* Regular data types: Must be in sync with zend_variables.c. */
|
/* Regular data types */
|
||||||
IS_UNDEF = 0,
|
IS_UNDEF,
|
||||||
IS_NULL = 1,
|
IS_NULL,
|
||||||
IS_FALSE = 2,
|
IS_FALSE,
|
||||||
IS_TRUE = 3,
|
IS_TRUE,
|
||||||
IS_LONG = 4,
|
IS_LONG,
|
||||||
IS_DOUBLE = 5,
|
IS_DOUBLE,
|
||||||
IS_STRING = 6,
|
IS_STRING,
|
||||||
IS_ARRAY = 7,
|
IS_ARRAY,
|
||||||
IS_OBJECT = 8,
|
IS_OBJECT,
|
||||||
IS_RESOURCE = 9,
|
IS_RESOURCE,
|
||||||
IS_REFERENCE = 10,
|
IS_REFERENCE,
|
||||||
IS_CONSTANT_AST = 11, /* Constant expressions */
|
IS_CONSTANT_AST, /* Constant expressions */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One after the largest regular data type; used internally
|
||||||
|
* for overlapping ranges below.
|
||||||
|
*/
|
||||||
|
_IS_REGULAR_END,
|
||||||
|
|
||||||
/* Fake types used only for type hinting.
|
/* Fake types used only for type hinting.
|
||||||
* These are allowed to overlap with the types below. */
|
* These are allowed to overlap with the types below. */
|
||||||
IS_CALLABLE = 12,
|
IS_CALLABLE = _IS_REGULAR_END,
|
||||||
IS_ITERABLE = 13,
|
IS_ITERABLE,
|
||||||
IS_VOID = 14,
|
IS_VOID,
|
||||||
IS_STATIC = 15,
|
IS_STATIC,
|
||||||
IS_MIXED = 16,
|
IS_MIXED,
|
||||||
IS_NEVER = 17,
|
IS_NEVER,
|
||||||
|
|
||||||
|
_IS_FAKE_END,
|
||||||
|
|
||||||
/* internal types */
|
/* internal types */
|
||||||
IS_INDIRECT = 12,
|
IS_INDIRECT = _IS_REGULAR_END,
|
||||||
IS_PTR = 13,
|
IS_PTR,
|
||||||
IS_ALIAS_PTR = 14,
|
IS_ALIAS_PTR,
|
||||||
_IS_ERROR = 15,
|
_IS_ERROR,
|
||||||
|
|
||||||
|
_IS_INTERNAL_END,
|
||||||
|
|
||||||
/* used for casts */
|
/* used for casts */
|
||||||
_IS_BOOL = 18,
|
_IS_BOOL = _IS_FAKE_END > _IS_INTERNAL_END ? _IS_FAKE_END : _IS_INTERNAL_END,
|
||||||
_IS_NUMBER = 19,
|
_IS_NUMBER,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZEND_SAME_FAKE_TYPE(faketype, realtype) ( \
|
|
||||||
(faketype) == (realtype) \
|
|
||||||
|| ((faketype) == _IS_BOOL && ((realtype) == IS_TRUE || (realtype) == IS_FALSE)) \
|
|
||||||
)
|
|
||||||
|
|
||||||
#endif /* ZEND_TYPE_CODE_H */
|
#endif /* ZEND_TYPE_CODE_H */
|
||||||
|
@ -51,6 +51,11 @@ static const zend_rc_dtor_func_t zend_rc_dtor_func[] = {
|
|||||||
[IS_CONSTANT_AST] = (zend_rc_dtor_func_t)zend_ast_ref_destroy
|
[IS_CONSTANT_AST] = (zend_rc_dtor_func_t)zend_ast_ref_destroy
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if ZEND_GCC_VERSION >= 4006 || defined(__clang__)
|
||||||
|
_Static_assert(sizeof(zend_rc_dtor_func) / sizeof(zend_rc_dtor_func[0]) == _IS_REGULAR_END,
|
||||||
|
"zend_rc_dtor_func has the wrong size");
|
||||||
|
#endif
|
||||||
|
|
||||||
ZEND_API void ZEND_FASTCALL rc_dtor_func(zend_refcounted *p)
|
ZEND_API void ZEND_FASTCALL rc_dtor_func(zend_refcounted *p)
|
||||||
{
|
{
|
||||||
ZEND_ASSERT(GC_TYPE(p) <= IS_CONSTANT_AST);
|
ZEND_ASSERT(GC_TYPE(p) <= IS_CONSTANT_AST);
|
||||||
|
Reference in New Issue
Block a user