Re: [PATCH 1/3] Add the callback_only attribute.

"H.J. Lu" <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <CAMe9rOpjnG3vKhqq40erH_gN-DQfa3Z4k52XouTgxy1GDBiQdw@mail.gmail.com>
On Mon, Jul 27, 2026 at 10:43 PM Josef Melcr <[email protected]> wrote:
>
> Changes since v4:
>  - Implemented Jakub's suggestions.
>    - The attribute is now available outside of the gnu namespace with
>      the __attribute__ syntax.
>    - Moved the attribute handler to c-family/c-attribs.cc.
>    - Removed the CALLBACK_ATTR_IDENT macro.
>
> I decided to update the names of identifiers, attribute lists and other
> things to keep things consistent with the new name.
>
> I moved the get_nth_list_elem to c-attribs.cc together with the
> attribute handler, but it will be removed by the next patch.  I decided
> to keep it in this patch solely to preserve the build, as I didn't want
> to make any changes to the functions being moved.
>
> Best regards,
> Josef
>
> gcc/ChangeLog:
>
>         * attr-callback.cc (callback_build_attr): Use "callback_only"
>         instead of the macro.
>         (callback_edge_callee_has_attr): Likewise.
>         (callback_fetch_attr_by_edge): Likewise.
>         (get_nth_list_elem): Move to c-family/c-attribs.cc.
>         (handle_callback_attribute): Rename to
>         handle_callback_only_attribute, move to c-family/c-attribs.cc.
>         * attr-callback.h (CALLBACK_ATTR_IDENT): Remove the macro.
>         (handle_callback_attribute): Remove the declaration.
>         * builtin-attrs.def (ATTR_CALLBACK): Rename to
>         ATTR_CALLBACK_ONLY.
>         (ATTR_CALLBACK_ONLY): Identifier for the attribute for builtins.
>         (DEF_CALLBACK_ATTRIBUTE): Rename to DEF_CALLBACK_ONLY_ATTRIBUTE.
>         (DEF_CALLBACK_ONLY_ATTRIBUTE): Renamed definition macro for builtins.
>         (GOMP): Use the renamed macro.
>         (ATTR_CALLBACK_GOMP_LIST): Renamed to
>         ATTR_CALLBACK_ONLY_GOMP_LIST.
>         (ATTR_CALLBACK_ONLY_GOMP_LIST): ATTR_NOTHROW_LIST with the
>         callback_only attribute for libgomp functions.
>         * cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee): Use
>         "callback_only" instead of the macro.
>         (cgraph_node::verify_node): Likewise.
>         * doc/extend.texi: Add callback_only attribute docs.
>         * ipa-cp.cc (purge_useless_callback_edges): Use "callback_only"
>         instead of the macro.
>         * ipa-param-manipulation.cc
>         (drop_decl_attribute_if_params_changed_p): Likewise.
>         * ipa-prop.cc (ipa_compute_jump_functions_for_edge): Likewise.
>         * omp-builtins.def (BUILT_IN_GOMP_PARALLEL_LOOP_STATIC): Use the
>         renamed attribute list.
>         (BUILT_IN_GOMP_PARALLEL_LOOP_GUIDED): Likewise.
>         (BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_DYNAMIC): Likewise.
>         (BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_RUNTIME): Likewise.
>         (BUILT_IN_GOMP_PARALLEL): Likewise.
>         (BUILT_IN_GOMP_PARALLEL_SECTIONS): Likewise.
>         (BUILT_IN_GOMP_TEAMS_REG): Likewise.
>         * tree-core.h: Update the ECF_CB flag comment.
>
> gcc/c-family/ChangeLog:
>
>         * c-attribs.cc (handle_callback_only_attribute): Moved from
>         attr-callback.cc.
>         (get_nth_list_elem): Likewise.
>
> gcc/fortran/ChangeLog:
>
>         * f95-lang.cc (ATTR_CALLBACK_GOMP_LIST): Rename to
>         ATTR_CALLBACK_ONLY_GOMP_LIST.
>         (ATTR_CALLBACK_ONLY_GOMP_LIST): Fortran counterpart for the
>         attribute list in builtin-attrs.def.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.dg/attr-callback.c: New test.
>         * gcc.dg/ipa/ipcp-cb2.c: New test.
>

On Linux/x86-64, I got

FAIL: gcc.dg/attr-callback.c  (test for errors, line 52)
FAIL: gcc.dg/attr-callback.c  (test for errors, line 56)
FAIL: gcc.dg/attr-callback.c  (test for errors, line 60)
FAIL: gcc.dg/attr-callback.c (test for excess errors)

-- 
H.J.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.