[PATCH] D27486: Correct class-template deprecation behavior

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 6 15:57:57 PST 2016


erichkeane added a comment.

In https://reviews.llvm.org/D27486#615174, @rsmith wrote:

> Thanks!
>
> If you look at `Sema::InstantiateClass`, we instantiate all of the attributes there. The problem seems to be that that happens only when instantiating the class definition, which happens after the point at which we would diagnose use of a deprecated declaration.
>
> This change will result in us having two copies of the `deprecated` attribute after we instantiate the class definition -- one from instantiating the declaration and another from instantiating the definition.


Well darn, I didn't notice this.

> Perhaps a better way to handle this would be to add a flag to the attribute definitions (in Attr.td) to indicate whether they apply to a declaration or just a definition (and thus whether they should be instantiated with a declaration, or only with a definition), and then instantiate the relevant subset when creating the `ClassTemplateSpecializationDecl` (and other kinds of decl -- I expect the same thing will happen for member classes of class templates, for function templates, and so on).

I can definitely look into this.  I have a feeling (based on the fact that this attribute IS picked up by function-template-instantiations) that it likely wouldn't be necessary for the others, but I can start to look into the scaffolding to get this to happen.

> @aaron.ballman Does that seem reasonable to you? If so, we should do some investigation of the attribute set to figure out what the best default is.

As far as this investigation, I'd suspect that the current behavior (never applies to declaration) is likely the correct 'default' is. I suspect that there is also a massive work-item to go through the current list to see which SHOULD apply to declarations.


https://reviews.llvm.org/D27486





More information about the cfe-commits mailing list