Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/Optimizer/zend_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ ZEND_API void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_fl
}
if (op_array->try_catch_array[i].finally_end) {
fprintf(stderr,
", %04u",
", %04u\n",
op_array->try_catch_array[i].finally_end);
} else {
fprintf(stderr, ", -\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ Error trying to add attributes to multiple constants at once

#[\Foo]
const First = 1,
Second = 2;
Second = 2,
Third = 3,
Fourth = 4;

?>
--EXPECTF--
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ static inline bool is_power_of_two(uint32_t n) {
return ((n != 0) && (n == (n & (~n + 1))));
}

ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *ast, zend_ast *op) {
ZEND_ATTRIBUTE_NODISCARD ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *ast, zend_ast *op) {
zend_ast_list *list = zend_ast_get_list(ast);
if (list->children >= 4 && is_power_of_two(list->children)) {
list = zend_ast_realloc(list,
Expand Down Expand Up @@ -2956,7 +2956,7 @@ zend_ast * ZEND_FASTCALL zend_ast_with_attributes(zend_ast *ast, zend_ast *attr)
/* Since constants are already stored in a list, just add the attributes
* to that list instead of storing them elsewhere;
* zend_compile_const_decl() checks the kind of the list elements. */
zend_ast_list_add(ast, attr);
ast = zend_ast_list_add(ast, attr);
break;
EMPTY_SWITCH_DEFAULT_CASE()
}
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ ZEND_API zend_ast *zend_ast_create_ex(zend_ast_kind kind, zend_ast_attr attr, ..
ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind kind, ...);
#endif

ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *list, zend_ast *op);
ZEND_ATTRIBUTE_NODISCARD ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *list, zend_ast *op);

ZEND_API zend_ast *zend_ast_create_decl(
zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment,
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -4391,7 +4391,7 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string
ZSTR_INIT_LITERAL("description", 0));
arg = zend_ast_create(ZEND_AST_NAMED_ARG, name, arg);
}
zend_ast_list_add((zend_ast *) args, arg);
args = (zend_ast_list *)zend_ast_list_add((zend_ast *) args, arg);
}

zend_compile_call_common(result, (zend_ast*)args, fbc, lineno);
Expand Down
8 changes: 8 additions & 0 deletions Zend/zend_portability.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ char *alloca();
# define ZEND_ATTRIBUTE_ALLOC_SIZE2(X,Y)
#endif

#if __STDC_VERSION__ >= 202311L || (defined(__cplusplus) && __cplusplus >= 201703L)
# define ZEND_ATTRIBUTE_NODISCARD [[nodiscard]]
#elif __has_attribute(__warn_unused_result__)
# define ZEND_ATTRIBUTE_NODISCARD __attribute__((__warn_unused_result__))
#else
# define ZEND_ATTRIBUTE_NODISCARD
#endif

#if ZEND_GCC_VERSION >= 3000
# define ZEND_ATTRIBUTE_CONST __attribute__((const))
#else
Expand Down
1 change: 1 addition & 0 deletions ext/opcache/tests/opt/gh18107_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ $_main:
0011 FAST_RET T5
EXCEPTION TABLE:
0006, -, 0007, 0011

Fatal error: Uncaught Exception: Should happen in %s:%d
Stack trace:
#0 {main}
Expand Down
1 change: 1 addition & 0 deletions ext/opcache/tests/opt/gh18107_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ $_main:
0015 RETURN int(1)
EXCEPTION TABLE:
0006, 0006, 0010, 0014

Fatal error: Uncaught Exception: Should happen in %s:%d
Stack trace:
#0 {main}
Expand Down