Allow arbitrary expressions in static variable initializer

Closes GH-9301
This commit is contained in:
Ilija Tovilo 2022-08-11 17:42:54 +02:00
parent 3189a9f94a
commit 0b1d750d91
No known key found for this signature in database
GPG key ID: A4F5D403F118200A
44 changed files with 1118 additions and 690 deletions

View file

@ -626,6 +626,9 @@ static zend_always_inline uint8_t zval_get_type(const zval* pz) {
#define Z_TYPE_FLAGS(zval) (zval).u1.v.type_flags
#define Z_TYPE_FLAGS_P(zval_p) Z_TYPE_FLAGS(*(zval_p))
#define Z_TYPE_EXTRA(zval) (zval).u1.v.u.extra
#define Z_TYPE_EXTRA_P(zval_p) Z_TYPE_EXTRA(*(zval_p))
#define Z_TYPE_INFO(zval) (zval).u1.type_info
#define Z_TYPE_INFO_P(zval_p) Z_TYPE_INFO(*(zval_p))
@ -752,6 +755,11 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
/* zval.u1.v.type_flags */
#define IS_TYPE_REFCOUNTED (1<<0)
#define IS_TYPE_COLLECTABLE (1<<1)
/* Used for static variables to check if they have been initialized. We can't use IS_UNDEF because
* we can't store IS_UNDEF zvals in the static_variables HashTable. This needs to live in type_info
* so that the ZEND_ASSIGN overrides it but is moved to extra to avoid breaking the Z_REFCOUNTED()
* optimization that only checks for Z_TYPE_FLAGS() without `& (IS_TYPE_COLLECTABLE|IS_TYPE_REFCOUNTED)`. */
#define IS_STATIC_VAR_UNINITIALIZED (1<<0)
#if 1
/* This optimized version assumes that we have a single "type_flag" */