On Mon, Feb 28, 2022 at 12:13:36PM -0400, Jason Merrill wrote: > On 2/25/22 17:59, Marek Polacek wrote: > > [ Most likely a GCC 13 patch, but I'm posting it now so that I don't lose > > it. ] > > > > When looking into the other PR I noticed that we fail to give a warning > > for a deprecated enumerator when the enum is in a class template. This > > only happens when the attribute doesn't have an argument. The reason is > > that when we tsubst_enum, we create a new enumerator: > > > > build_enumerator (DECL_NAME (decl), value, newtag, > > DECL_ATTRIBUTES (decl), DECL_SOURCE_LOCATION (decl)); > > > > but DECL_ATTRIBUTES (decl) is null when the attribute was provided > > without an argument -- in that case it simply melts into a tree flag. > > handle_deprecated_attribute has: > > > > if (!args) > > *no_add_attrs = true; > > > > so the attribute isn't retained and we lose it when tsubsting. Same > > thing when the attribute is on the enum itself. > > > > Attribute unavailable is a similar case, but it's different in that > > it can be a late attribute whereas "deprecated" can't: > > Iain, was this difference intentional?
FWIW, I'm in favor of treating deprecated/unavailable the same, that is, adding unavailable... > > is_late_template_attribute has > > > > /* But some attributes specifically apply to templates. */ > > && !is_attribute_p ("abi_tag", name) > > && !is_attribute_p ("deprecated", name) ...here. But that really does seem like a GCC 13 change. > > && !is_attribute_p ("visibility", name)) > > return true; > > else > > return false; > > > > which looks strange, but attr-unavailable-9.C tests that we don't error when > > the attribute is applied on a template. > > > > Bootstrapped/regtested on x86_64-pc-linux-gnu. > > This looks extremely safe, so let's go ahead and apply it to trunk. Will do, thanks. Marek