Clang suggests wrong attribute placement for enum classes
Consider this code:
__attribute__((deprecated))
enum class F {
Foo,
Bar
};
clang suggests:
<source>:3:16: warning: attribute 'deprecated' is ignored, place it after "enum" to apply attribute to type declaration [-Wignored-attributes]
__attribute__((deprecated))
Godbolt: https://godbolt.org/z/E4vT1dc57
But placing them after "enum" is wrong, too:
<source>:4:6: error: an attribute list cannot appear here
enum __attribute__((deprecated)) class F {
^~~~~~~~~~~~~~~~~~~~~~~~~~~
Godbolt: https://godbolt.org/z/PWvd8jsr5
@llvm/issue-subscribers-good-first-issue
@tbaederr sir maybe this warning is shown because this compiler may not support applying attributes to the underlying type of an enum class. Is it possible? Can you suggest something.
The attributes just need to go after 'enum class': https://godbolt.org/z/441Pnq64G
The attributes just need to go after 'enum class': https://godbolt.org/z/441Pnq64G
@tbaederr Yaa, I have been doing the same thing. It has been resolved.
@llvmbot @tbaederr can i claim this issue and create a pr to fix it?
I haven't seen another patch so yes.
@tbaederr @antara-gandhi sorry I have been working on this and I am submitting the patch on this issue just I am getting one problem on submitting patch which I am discussing with mentor.
I was working on the patch as well but did not mention in this thread! You can continue @sagar10arya, I will revert back.
GCC rightly captures this warning at place,very useful for clang as well.

@Krishna-13-cyber cool I will go on with this thanks.
I think the error message should be changed to say that it should come after "enum class" instead of "enum".
I am an Outreachy applicant and I want to work on this issue.
Can anyone please tell me that whether TST_enum_class is a predefined declaration specifier or not? If not, then how can I identify enum class?
@sagar10arya hey, are you still working on this? If not I could try to pick it up
@sagar10arya hey, are you still working on this? If not I could try to pick it up
Hi! @krishenm94, I have resolved the issue. Now I am working on the tests. https://reviews.llvm.org/D147989