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
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, thanks

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