diff --git a/Zend/Optimizer/zend_call_graph.h b/Zend/Optimizer/zend_call_graph.h index 57c6bdffe998..e3d160f6bea3 100644 --- a/Zend/Optimizer/zend_call_graph.h +++ b/Zend/Optimizer/zend_call_graph.h @@ -38,7 +38,7 @@ struct _zend_call_info { bool is_prototype; /* An overridden child method may be called */ bool is_frameless; /* A frameless function sends arguments through operands */ uint32_t num_args; /* Number of arguments, excluding named and variadic arguments */ - zend_send_arg_info arg_info[1]; + zend_send_arg_info arg_info[1] ZEND_ATTRIBUTE_FLEX_ARRAY; }; struct _zend_func_info { diff --git a/Zend/zend.h b/Zend/zend.h index 29863fba687c..6d8493ef8b18 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -94,7 +94,7 @@ typedef struct _zend_trait_method_reference { typedef struct _zend_trait_precedence { zend_trait_method_reference trait_method; uint32_t num_excludes; - zend_string *exclude_class_names[1]; + zend_string *exclude_class_names[1] ZEND_ATTRIBUTE_FLEX_ARRAY; } zend_trait_precedence; typedef struct _zend_trait_alias { @@ -140,7 +140,7 @@ struct _zend_inheritance_cache_entry { uint32_t dependencies_count; uint32_t num_warnings; zend_error_info **warnings; - zend_class_entry *traits_and_interfaces[1]; + zend_class_entry *traits_and_interfaces[1] ZEND_ATTRIBUTE_FLEX_ARRAY; }; C23_ENUM(zend_class_type, uint8_t) { diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h index 5d646f428c1b..8b363fd4d181 100644 --- a/Zend/zend_ast.h +++ b/Zend/zend_ast.h @@ -188,7 +188,7 @@ struct _zend_ast { zend_ast_kind kind; /* Type of the node (ZEND_AST_* enum constant) */ zend_ast_attr attr; /* Additional attribute, use depending on node type */ uint32_t lineno; /* Line number */ - zend_ast *child[1]; /* Array of children (using struct hack) */ + zend_ast *child[1] ZEND_ATTRIBUTE_FLEX_ARRAY; /* Array of children (using struct hack) */ }; /* Same as zend_ast, but with children count, which is updated dynamically */ @@ -197,7 +197,7 @@ typedef struct _zend_ast_list { zend_ast_attr attr; uint32_t lineno; uint32_t children; - zend_ast *child[1]; + zend_ast *child[1] ZEND_ATTRIBUTE_FLEX_ARRAY; } zend_ast_list; /* Lineno is stored in val.u2.lineno */ diff --git a/Zend/zend_attributes.h b/Zend/zend_attributes.h index d26923a0fcf0..f88469025ae3 100644 --- a/Zend/zend_attributes.h +++ b/Zend/zend_attributes.h @@ -76,7 +76,7 @@ typedef struct _zend_attribute { * Everything else uses 0. */ uint32_t offset; uint32_t argc; - zend_attribute_arg args[1]; + zend_attribute_arg args[1] ZEND_ATTRIBUTE_FLEX_ARRAY; } zend_attribute; typedef struct _zend_internal_attribute { diff --git a/Zend/zend_llist.h b/Zend/zend_llist.h index a92b8a59648c..b5e5701ef49f 100644 --- a/Zend/zend_llist.h +++ b/Zend/zend_llist.h @@ -24,7 +24,7 @@ typedef struct _zend_llist_element { struct _zend_llist_element *next; struct _zend_llist_element *prev; - char data[1]; /* Needs to always be last in the struct */ + char data[1] ZEND_ATTRIBUTE_FLEX_ARRAY; /* Needs to always be last in the struct */ } zend_llist_element; typedef void (*llist_dtor_func_t)(void *); diff --git a/Zend/zend_partial.c b/Zend/zend_partial.c index 346b94400567..70cc9ba1aa67 100644 --- a/Zend/zend_partial.c +++ b/Zend/zend_partial.c @@ -137,7 +137,7 @@ typedef struct zp_names { zend_string *variadic_param; zend_string *extra_named_params; zend_string *inner_closure; - zend_string *params[1]; /* argc elements */ + zend_string *params[1] ZEND_ATTRIBUTE_FLEX_ARRAY; /* argc elements */ } zp_names; static bool zp_name_exists(const zp_names *names, uint32_t argc, const zend_string *name) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 612de777869a..862a449ea256 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -396,6 +396,12 @@ char *alloca(); # define HAVE_BUILTIN_CONSTANT_P #endif +#if __has_attribute(strict_flex_array) +# define ZEND_ATTRIBUTE_FLEX_ARRAY __attribute__((strict_flex_array(1))) +#else +# define ZEND_ATTRIBUTE_FLEX_ARRAY +#endif + #if __has_attribute(counted_by) #define ZEND_ELEMENT_COUNT(m) __attribute__((counted_by(m))) #else diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c index 84437789812b..677ff8c418a6 100644 --- a/Zend/zend_strtod.c +++ b/Zend/zend_strtod.c @@ -536,7 +536,7 @@ BCinfo { int dp0, dp1, dplen, dsign, e0, inexact, nd, nd0, rounding, scale, uflc Bigint { struct Bigint *next; int k, maxwds, sign, wds; - ULong x[1]; + ULong x[1] ZEND_ATTRIBUTE_FLEX_ARRAY; }; typedef struct Bigint Bigint; diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 465798a4e6ce..e6c927fd313d 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -124,7 +124,7 @@ typedef struct { typedef struct { uint32_t num_types; - zend_type types[1]; + zend_type types[1] ZEND_ATTRIBUTE_FLEX_ARRAY; } zend_type_list; #define _ZEND_TYPE_EXTRA_FLAGS_SHIFT 25 @@ -380,7 +380,7 @@ struct _zend_string { zend_refcounted_h gc; zend_ulong h; /* hash value */ size_t len; - char val[1]; + char val[1] ZEND_ATTRIBUTE_FLEX_ARRAY; }; typedef struct _Bucket { @@ -604,7 +604,7 @@ struct _zend_object { zend_class_entry *ce; const zend_object_handlers *handlers; HashTable *properties; - zval properties_table[1]; + zval properties_table[1] ZEND_ATTRIBUTE_FLEX_ARRAY; }; struct _zend_resource { @@ -617,7 +617,7 @@ struct _zend_resource { typedef struct { size_t num; size_t num_allocated; - struct _zend_property_info *ptr[1]; + struct _zend_property_info *ptr[1] ZEND_ATTRIBUTE_FLEX_ARRAY; } zend_property_info_list; typedef union { diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h index 5fb620054beb..de3842329b1f 100644 --- a/ext/opcache/jit/zend_jit_internal.h +++ b/ext/opcache/jit/zend_jit_internal.h @@ -168,7 +168,7 @@ typedef struct _zend_jit_op_array_hot_extension { zend_func_info func_info; const zend_op_array *op_array; int16_t *counter; - zend_vm_opcode_handler_t orig_handlers[1]; + zend_vm_opcode_handler_t orig_handlers[1] ZEND_ATTRIBUTE_FLEX_ARRAY; } zend_jit_op_array_hot_extension; #define zend_jit_op_array_hash(op_array) \ @@ -352,7 +352,7 @@ typedef struct _zend_jit_op_array_trace_extension { zend_func_info func_info; const zend_op_array *op_array; size_t offset; /* offset from "zend_op" to corresponding "op_info" */ - zend_op_trace_info trace_info[1]; + zend_op_trace_info trace_info[1] ZEND_ATTRIBUTE_FLEX_ARRAY; } zend_jit_op_array_trace_extension; #define ZEND_OP_TRACE_INFO(opline, offset) \ @@ -574,7 +574,7 @@ struct _zend_jit_trace_stack_frame { int used_stack; int old_checked_stack; int old_peek_checked_stack; - zend_jit_trace_stack stack[1]; + zend_jit_trace_stack stack[1] ZEND_ATTRIBUTE_FLEX_ARRAY; }; #define TRACE_FRAME_SHIFT_NUM_ARGS 16 diff --git a/main/fastcgi.c b/main/fastcgi.c index 84f5ad58d8be..1993cdf5eecd 100644 --- a/main/fastcgi.c +++ b/main/fastcgi.c @@ -174,7 +174,7 @@ typedef struct _fcgi_data_seg { char *pos; char *end; struct _fcgi_data_seg *next; - char data[1]; + char data[1] ZEND_ATTRIBUTE_FLEX_ARRAY; } fcgi_data_seg; typedef struct _fcgi_hash { diff --git a/sapi/phpdbg/phpdbg_list.h b/sapi/phpdbg/phpdbg_list.h index 5001af05ba7b..c00d7d90416a 100644 --- a/sapi/phpdbg/phpdbg_list.h +++ b/sapi/phpdbg/phpdbg_list.h @@ -42,7 +42,7 @@ typedef struct { size_t len; zend_op_array op_array; uint32_t lines; - uint32_t line[1]; + uint32_t line[1] ZEND_ATTRIBUTE_FLEX_ARRAY; } phpdbg_file_source; #endif /* PHPDBG_LIST_H */