[PATCH] D147989: [clang] Fix Attribute Placement
Priyanshi Agarwal via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 11 07:19:23 PDT 2023
ipriyanshi1708 updated this revision to Diff 512445.
ipriyanshi1708 added a comment.
Applied C++ Overloading
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147989/new/
https://reviews.llvm.org/D147989
Files:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDecl.cpp
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5043,7 +5043,18 @@
llvm_unreachable("unexpected type specifier");
}
}
-
+static unsigned GetDiagnosticTypeSpecifierID(const DeclSpec &DS){
+ if (DS.getTypeSpecType() == DeclSpec::TST_enum) {
+ if (const EnumDecl *ED = dyn_cast<EnumDecl>(DS.getRepAsDecl())) {
+ if (ED->isScopedUsingClassTag())
+ return 5;
+ }
+ }
+ else{
+ return GetDiagnosticTypeSpecifierID(DS.getTypeSpecType());
+ }
+ return 0;
+}
/// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
/// no declarator (e.g. "struct foo;") is parsed. It also accepts template
/// parameters to cope with template friend declarations.
@@ -5300,11 +5311,11 @@
TypeSpecType == DeclSpec::TST_enum) {
for (const ParsedAttr &AL : DS.getAttributes())
Diag(AL.getLoc(), diag::warn_declspec_attribute_ignored)
- << AL << GetDiagnosticTypeSpecifierID(TypeSpecType);
+ << AL << GetDiagnosticTypeSpecifierID(DS);
for (const ParsedAttr &AL : DeclAttrs)
Diag(AL.getLoc(), diag::warn_declspec_attribute_ignored)
- << AL << GetDiagnosticTypeSpecifierID(TypeSpecType);
- }
+ << AL << GetDiagnosticTypeSpecifierID(DS);
+ }
}
return TagD;
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3421,7 +3421,7 @@
InGroup<DeprecatedAttributes>;
def warn_declspec_attribute_ignored : Warning<
"attribute %0 is ignored, place it after "
- "\"%select{class|struct|interface|union|enum}1\" to apply attribute to "
+ "\"%select{class|struct|interface|union|enum|enum class}1\" to apply attribute to "
"type declaration">, InGroup<IgnoredAttributes>;
def warn_attribute_precede_definition : Warning<
"attribute declaration must precede definition">,
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -193,6 +193,8 @@
Bug Fixes to Attribute Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+- Fixed a bug where attribute annotations on type specifiers (enums, classes, structs, unions, and scoped enums) were not properly ignored, resulting in misleading warning messages. Now, such attribute annotations are correctly ignored.
+(`#61660 <https://github.com/llvm/llvm-project/issues/61660>`_)
Bug Fixes to C++ Support
^^^^^^^^^^^^^^^^^^^^^^^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147989.512445.patch
Type: text/x-patch
Size: 2720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230411/096c6d8f/attachment-0001.bin>
More information about the cfe-commits
mailing list