File tree 12 files changed +21
-13
lines changed 12 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ struct _zend_call_info {
39
39
bool named_args ; /* Function has named arguments */
40
40
bool is_prototype ; /* An overridden child method may be called */
41
41
int num_args ; /* Number of arguments, excluding named and variadic arguments */
42
- zend_send_arg_info arg_info [1 ];
42
+ zend_send_arg_info arg_info [1 ] ZEND_ELEMENT_COUNT ( num_args ) ;
43
43
};
44
44
45
45
struct _zend_func_info {
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ typedef struct _zend_trait_method_reference {
95
95
typedef struct _zend_trait_precedence {
96
96
zend_trait_method_reference trait_method ;
97
97
uint32_t num_excludes ;
98
- zend_string * exclude_class_names [1 ];
98
+ zend_string * exclude_class_names [1 ] ZEND_ELEMENT_COUNT ( num_excludes ) ;
99
99
} zend_trait_precedence ;
100
100
101
101
typedef struct _zend_trait_alias {
Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ typedef struct _zend_ast_list {
191
191
zend_ast_attr attr ;
192
192
uint32_t lineno ;
193
193
uint32_t children ;
194
- zend_ast * child [1 ];
194
+ zend_ast * child [1 ] ZEND_ELEMENT_COUNT ( children ) ;
195
195
} zend_ast_list ;
196
196
197
197
/* Lineno is stored in val.u2.lineno */
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ typedef struct _zend_attribute {
58
58
/* Parameter offsets start at 1, everything else uses 0. */
59
59
uint32_t offset ;
60
60
uint32_t argc ;
61
- zend_attribute_arg args [1 ];
61
+ zend_attribute_arg args [1 ] ZEND_ELEMENT_COUNT ( argc ) ;
62
62
} zend_attribute ;
63
63
64
64
typedef struct _zend_internal_attribute {
Original file line number Diff line number Diff line change @@ -327,6 +327,14 @@ char *alloca();
327
327
# define HAVE_BUILTIN_CONSTANT_P
328
328
#endif
329
329
330
+ #if __has_attribute(element_count)
331
+ #define ZEND_ELEMENT_COUNT (m ) __attribute__((element_count(m)))
332
+ #elif __has_attribute(counted_by)
333
+ #define ZEND_ELEMENT_COUNT (m ) __attribute__((counted_by(m)))
334
+ #else
335
+ #define ZEND_ELEMENT_COUNT (m )
336
+ #endif
337
+
330
338
#ifdef HAVE_BUILTIN_CONSTANT_P
331
339
# define ZEND_CONST_COND (_condition, _default ) \
332
340
(__builtin_constant_p(_condition) ? (_condition) : (_default))
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ typedef struct {
139
139
140
140
typedef struct {
141
141
uint32_t num_types ;
142
- zend_type types [1 ];
142
+ zend_type types [1 ] ZEND_ELEMENT_COUNT ( num_types ) ;
143
143
} zend_type_list ;
144
144
145
145
#define _ZEND_TYPE_EXTRA_FLAGS_SHIFT 25
@@ -374,7 +374,7 @@ struct _zend_string {
374
374
zend_refcounted_h gc ;
375
375
zend_ulong h ; /* hash value */
376
376
size_t len ;
377
- char val [1 ];
377
+ char val [1 ] ZEND_ELEMENT_COUNT ( len ) ;
378
378
};
379
379
380
380
typedef struct _Bucket {
@@ -572,7 +572,7 @@ struct _zend_resource {
572
572
typedef struct {
573
573
size_t num ;
574
574
size_t num_allocated ;
575
- struct _zend_property_info * ptr [1 ];
575
+ struct _zend_property_info * ptr [1 ] ZEND_ELEMENT_COUNT ( num ) ;
576
576
} zend_property_info_list ;
577
577
578
578
typedef union {
Original file line number Diff line number Diff line change @@ -912,7 +912,7 @@ typedef struct _zend_ffi_callback_data {
912
912
ffi_cif cif ;
913
913
uint32_t arg_count ;
914
914
ffi_type * ret_type ;
915
- ffi_type * arg_types [0 ];
915
+ ffi_type * arg_types [0 ] ZEND_ELEMENT_COUNT ( arg_count ) ;
916
916
} zend_ffi_callback_data ;
917
917
918
918
static void zend_ffi_callback_hash_dtor (zval * zv ) /* {{{ */
Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ typedef struct {
277
277
278
278
typedef struct {
279
279
size_t cat_num ;
280
- cdf_catalog_entry_t cat_e [1 ];
280
+ cdf_catalog_entry_t cat_e [1 ] ZEND_ELEMENT_COUNT ( cat_num ) ;
281
281
} cdf_catalog_t ;
282
282
283
283
struct timespec ;
Original file line number Diff line number Diff line change @@ -538,7 +538,7 @@ struct _zend_jit_trace_stack_frame {
538
538
int used_stack ;
539
539
int old_checked_stack ;
540
540
int old_peek_checked_stack ;
541
- zend_jit_trace_stack stack [1 ];
541
+ zend_jit_trace_stack stack [1 ] ZEND_ELEMENT_COUNT ( used_stack ) ;
542
542
};
543
543
544
544
#define TRACE_FRAME_SHIFT_NUM_ARGS 16
Original file line number Diff line number Diff line change 142
142
typedef struct _ir_refs {
143
143
uint32_t count;
144
144
uint32_t limit;
145
- ir_ref refs[0];
145
+ ir_ref refs[0] ZEND_ELEMENT_COUNT(count) ;
146
146
} ir_refs;
147
147
148
148
#define ir_refs_size(_n) (offsetof(ir_refs, refs) + sizeof(ir_ref) * (_n))
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ struct fpm_scoreboard_s {
67
67
int free_proc ;
68
68
unsigned long int slow_rq ;
69
69
struct fpm_scoreboard_s * shared ;
70
- struct fpm_scoreboard_proc_s procs [];
70
+ struct fpm_scoreboard_proc_s procs [] ZEND_ELEMENT_COUNT ( nprocs ) ;
71
71
};
72
72
73
73
int fpm_scoreboard_init_main (void );
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ typedef struct {
44
44
size_t len ;
45
45
zend_op_array op_array ;
46
46
uint32_t lines ;
47
- uint32_t line [1 ];
47
+ uint32_t line [1 ] ZEND_ELEMENT_COUNT ( lines ) ;
48
48
} phpdbg_file_source ;
49
49
50
50
#endif /* PHPDBG_LIST_H */
You can’t perform that action at this time.
0 commit comments