diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 44906456f3371..e5c93a6a732bf 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -6835,10 +6835,11 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, // though they were unknown attributes. if (AL.getKind() == ParsedAttr::UnknownAttribute || !AL.existsInTarget(S.Context.getTargetInfo())) { - if (AL.isRegularKeywordAttribute() || AL.isDeclspecAttribute()) { - S.Diag(AL.getLoc(), AL.isRegularKeywordAttribute() - ? diag::err_keyword_not_supported_on_target - : diag::warn_unhandled_ms_attribute_ignored) + if (AL.isRegularKeywordAttribute()) { + S.Diag(AL.getLoc(), diag::err_keyword_not_supported_on_target) + << AL.getAttrName() << AL.getRange(); + } else if (AL.isDeclspecAttribute()) { + S.Diag(AL.getLoc(), diag::warn_unhandled_ms_attribute_ignored) << AL.getAttrName() << AL.getRange(); } else { S.DiagnoseUnknownAttribute(AL); diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index 77aa7164d4555..50acc83f1841c 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -672,10 +672,11 @@ static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A, !(A.existsInTarget(S.Context.getTargetInfo()) || (S.Context.getLangOpts().SYCLIsDevice && Aux && A.existsInTarget(*Aux)))) { - if (A.isRegularKeywordAttribute() || A.isDeclspecAttribute()) { - S.Diag(A.getLoc(), A.isRegularKeywordAttribute() - ? diag::err_keyword_not_supported_on_target - : diag::warn_unhandled_ms_attribute_ignored) + if (A.isRegularKeywordAttribute()) { + S.Diag(A.getLoc(), diag::err_keyword_not_supported_on_target) + << A << A.getRange(); + } else if (A.isDeclspecAttribute()) { + S.Diag(A.getLoc(), diag::warn_unhandled_ms_attribute_ignored) << A << A.getRange(); } else { S.DiagnoseUnknownAttribute(A);