diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3421,7 +3421,7 @@ InGroup; 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; def warn_attribute_precede_definition : Warning< "attribute declaration must precede definition">, diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -271,7 +271,6 @@ TSC_imaginary, TSC_complex }; - // Import type specifier type enumeration and constants. typedef TypeSpecifierType TST; static const TST TST_unspecified = clang::TST_unspecified; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -55,7 +55,7 @@ using namespace clang; using namespace sema; - +bool isEnumClass = false; Sema::DeclGroupPtrTy Sema::ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType) { if (OwnedType) { Decl *Group[2] = { OwnedType, Ptr }; @@ -5028,6 +5028,9 @@ } static unsigned GetDiagnosticTypeSpecifierID(DeclSpec::TST T) { + if (isEnumClass) { + return 5; + }else{ switch (T) { case DeclSpec::TST_class: return 0; @@ -5042,6 +5045,7 @@ default: llvm_unreachable("unexpected type specifier"); } + } } /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with @@ -5298,13 +5302,19 @@ TypeSpecType == DeclSpec::TST_interface || TypeSpecType == DeclSpec::TST_union || TypeSpecType == DeclSpec::TST_enum) { + if (TypeSpecType == DeclSpec::TST_enum) { + if (const EnumDecl *ED = dyn_cast(DS.getRepAsDecl())) { + if (ED->isScopedUsingClassTag()) + isEnumClass = true; + } + } for (const ParsedAttr &AL : DS.getAttributes()) Diag(AL.getLoc(), diag::warn_declspec_attribute_ignored) << AL << GetDiagnosticTypeSpecifierID(TypeSpecType); for (const ParsedAttr &AL : DeclAttrs) Diag(AL.getLoc(), diag::warn_declspec_attribute_ignored) << AL << GetDiagnosticTypeSpecifierID(TypeSpecType); - } + } } return TagD;