Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Support attribute deprecated for template alias #17861

Open Quuxplusone opened 11 years ago

Quuxplusone commented 11 years ago
Bugzilla Link PR17862
Status NEW
Importance P enhancement
Reported by agenda2010@grueninger.de
Reported on 2013-11-09 03:53:08 -0800
Last modified on 2021-10-18 14:38:03 -0700
Version trunk
Hardware PC Linux
CC dgregor@apple.com, llvm-bugs@lists.llvm.org, pipping@exherbo.org, vsna7ma4he@jorrit.de
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
I want to rename a templated class. To make the transition easier for the
users, I'd like to keep the old class for one more version and mark it
deprecated with the extensions from GCC / Clang (attribute deprecated). To
avoid keeping an exact copy of the deprecated class, the use of template alias
would be handy. Unfortunately Clang (3.3 and recent trunk) does not emit a
warning (GCC does) for the following code in line 14:

template <class T>
struct NewClassName
{
    // ...
};

template <class T> using OldClassNameUsing __attribute__ ((deprecated))
  = NewClassName<T>;

typedef NewClassName<int> OldClassNameTypedef __attribute__ ((deprecated));

int main()
{
  OldClassNameUsing<int> objectUsing;
  OldClassNameTypedef objectTypedef;

  return 0;
}

Clang used:
clang version 3.4 (194323)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Quuxplusone commented 9 years ago
To state the problem more precisely, the deprecation message is only missing
when templates are not specified.

template <class T>
struct NewClassName
{
    // ...
};

template <class T> using OldClassNameUsing __attribute__ ((deprecated))
  = NewClassName<T>;

using OldClassNameWithoutTemplateUsing __attribute__ ((deprecated))
  = NewClassName<int>;

typedef NewClassName<int> OldClassNameTypedef __attribute__ ((deprecated));

int main()
{
  OldClassNameUsing<int> objectUsing;  // no deprecation warning
  OldClassNameWithoutTemplateUsing objectWithoutTemplateUsing; // emits warning
  OldClassNameTypedef objectTypedef;   // emits warning

  return 0;
}
Quuxplusone commented 6 years ago
This has bitten us again: https://gitlab.dune-project.org/core/dune-
common/merge_requests/464#note_41116

All versions of clang up to 5.0 seem to be affected according to godbolt:
https://godbolt.org/g/Cpsbd7

godbolt does not support clang 6 at the moment, so I can't easily test that.

All forms of deprecating seem to be affected: [[deprecated(msg)]],
__attribute__((__deprecated__(msg))), __attribute__((deprecated(msg)))
Quuxplusone commented 3 years ago

Still an issue with Clang 13.