@@ -915,6 +915,7 @@ static bool checkObjCDeclContext(Decl *D) {
915
915
}
916
916
917
917
static void diagnoseObjCAttrWithoutFoundation (ObjCAttr *attr, Decl *decl,
918
+ ObjCReason reason,
918
919
DiagnosticBehavior behavior) {
919
920
auto *SF = decl->getDeclContext ()->getParentSourceFile ();
920
921
assert (SF);
@@ -949,6 +950,7 @@ static void diagnoseObjCAttrWithoutFoundation(ObjCAttr *attr, Decl *decl,
949
950
ctx.Id_Foundation )
950
951
.highlight (attr->getRangeWithAt ())
951
952
.limitBehavior (behavior);
953
+ reason.describe (decl);
952
954
}
953
955
954
956
void AttributeChecker::visitObjCAttr (ObjCAttr *attr) {
@@ -991,6 +993,7 @@ void AttributeChecker::visitObjCAttr(ObjCAttr *attr) {
991
993
992
994
if (error) {
993
995
diagnoseAndRemoveAttr (attr, *error).limitBehavior (behavior);
996
+ reason.describe (D);
994
997
return ;
995
998
}
996
999
@@ -1078,10 +1081,11 @@ void AttributeChecker::visitObjCAttr(ObjCAttr *attr) {
1078
1081
// Enum elements require names.
1079
1082
diagnoseAndRemoveAttr (attr, diag::objc_enum_case_req_name)
1080
1083
.limitBehavior (behavior);
1084
+ reason.describe (D);
1081
1085
}
1082
1086
1083
1087
// Diagnose an @objc attribute used without importing Foundation.
1084
- diagnoseObjCAttrWithoutFoundation (attr, D, behavior);
1088
+ diagnoseObjCAttrWithoutFoundation (attr, D, reason, behavior);
1085
1089
}
1086
1090
1087
1091
void AttributeChecker::visitNonObjCAttr (NonObjCAttr *attr) {
@@ -1190,6 +1194,12 @@ void TypeChecker::checkDeclAttributes(Decl *D) {
1190
1194
else
1191
1195
Checker.diagnoseAndRemoveAttr (attr, diag::invalid_decl_attribute, attr)
1192
1196
.limitBehavior (behavior);
1197
+
1198
+ if (attr->getAddedByAccessNote ()) {
1199
+ auto notesFileReason = D->getModuleContext ()->getAccessNotes ().Reason ;
1200
+ D->diagnose (diag::note_invalid_attr_added_by_access_note,
1201
+ attr->isDeclModifier (), attr->getAttrName (), notesFileReason);
1202
+ }
1193
1203
}
1194
1204
Checker.checkOriginalDefinedInAttrs (D, ODIAttrs);
1195
1205
}
0 commit comments