On 14/12/2024 04:34, Marek Polacek wrote: >> @@ -1376,6 +1377,13 @@ maybe_add_lambda_conv_op (tree type) >> if (generic_lambda_p) >> fn = add_inherited_template_parms (fn, DECL_TI_TEMPLATE (callop)); >> >> + if (lookup_attribute ("section", DECL_ATTRIBUTES (callop))) >> + { >> + duplicate_one_attribute(&DECL_ATTRIBUTES (fn), >> + DECL_ATTRIBUTES (callop), "section"); >> + set_decl_section_name (statfn, callop); >> + } > > duplicate_one_attribute does two lookups, but we just looked up the > callop attr, and we just built up fn so it shouldn't have any attrs. > Thus I wonder if writing it like this would be a little neater: > > if (tree a = lookup_attribute ("section", DECL_ATTRIBUTES (callop))) > { > DECL_ATTRIBUTES (fn) = attr_chainon (DECL_ATTRIBUTES (fn), a); > set_decl_section_name (fn, callop); > }
I'm regtesting that now, then I'll send it in as a V2 of this patch? > Sadly I see that just the set_decl_section_name call wouldn't be enough... Right - the problem I found was that functions are only allowed to have both a section (per decl_section_name) and a comdat group if they've got a section attribute. Setting the attribute seemed a lot cleaner than adding a check at the time of validation.