https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118339
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Alfie Richards <[email protected]>: https://gcc.gnu.org/g:3cc894e7c38c6ffaaa79ae92181b32c248f0d837 commit r16-4038-g3cc894e7c38c6ffaaa79ae92181b32c248f0d837 Author: Alfie Richards <[email protected]> Date: Mon Mar 24 15:04:38 2025 +0000 fmv: c++: Add check_target_clone hook for filtering target_clone versions. This patch introduces the TARGET_CHECK_TARGET_CLONE_VERSION hook which is used to determine if a target_clones version string parses. The hook has a flag to enable emitting diagnostics. This is as specified in the Arm C Language Extension. The purpose of this is to be able to ignore invalid versions to allow some portability of code using target_clones attributes. Currently this is only properly implemented for the Aarch64 backend. For riscv which is the only other backend which uses target_version semantics a partial implementation is present, where this hook is used to check parsing, in which errors will be emitted on a failed parse rather than warnings. A refactor of the riscv parsing logic would be required to enable this functionality fully. This fixes PR 118339 where parse failures could cause ICE in Aarch64. gcc/ChangeLog: PR target/118339 * target.def: Add check_target_clone_version hook. * tree.cc (get_clone_attr_versions): Add filter argument. (get_clone_versions): Add filter argument. * tree.h (get_clone_attr_versions): Add filter. (get_clone_versions): Add filter argument. * config/aarch64/aarch64.cc (aarch64_check_target_clone_version): New function (TARGET_CHECK_TARGET_CLONE_VERSION): New define. * config/riscv/riscv.cc (riscv_check_target_clone_version): New function. (TARGET_CHECK_TARGET_CLONE_VERSION): New define. * doc/tm.texi: Regenerated. * doc/tm.texi.in: Add documentation for new hook. * hooks.h (hook_stringslice_locationtptr_true): New function. * hooks.cc (hook_stringslice_locationtptr_true): New function. gcc/c-family/ChangeLog: * c-attribs.cc (handle_target_clones_attribute): Update to use new hook.
