On Tue, 12 Aug 2025, David Faust wrote:

> +  if (TREE_CODE (*node) == FUNCTION_TYPE || TREE_CODE (*node) == METHOD_TYPE)
> +    {
> +      /* Treat btf_type_tag applied to a function type as applying to the
> +      return type instead.  Otherwise with GNU syntax there is no way to
> +      apply type_tag to the return type; the parser always associates it
> +      to the function_type node.  btf_decl_tag can (should) be used to
> +      annotate the function itself.  */
> +      tree ret_type = TREE_TYPE (*node);
> +      tree new_attrs = tree_cons (name, args, TYPE_ATTRIBUTES (ret_type));
> +      tree new_type = build_type_attribute_qual_variant (ret_type,
> +                                                      new_attrs,
> +                                                      TYPE_QUALS (ret_type));
> +      TREE_TYPE (*node) = new_type;

Is there some reason it's impossible for the function type here to be in 
use for any other declaration?  If not, modifying the return type of the 
existing function type in-place like this seems unsafe.

-- 
Joseph S. Myers
josmy...@redhat.com

Reply via email to