Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -7221,6 +7221,8 @@ SmallVector AvailabilityStack; SmallVector StmtStack; + SourceRange CurrentRange; + void DiagnoseDeclAvailability(NamedDecl *D, SourceRange Range); public: @@ -7234,7 +7236,10 @@ if (!S) return true; StmtStack.push_back(S); + SourceRange LastRange(S->getLocStart(), S->getLocEnd()); + std::swap(LastRange, CurrentRange); bool Result = Base::TraverseStmt(S); + std::swap(LastRange, CurrentRange); StmtStack.pop_back(); return Result; } @@ -7370,21 +7375,18 @@ bool DiagnoseUnguardedAvailability::VisitTypeLoc(TypeLoc Ty) { const Type *TyPtr = Ty.getTypePtr(); - SourceRange Range{Ty.getBeginLoc(), Ty.getEndLoc()}; - if (const TagType *TT = dyn_cast(TyPtr)) { TagDecl *TD = TT->getDecl(); - DiagnoseDeclAvailability(TD, Range); + DiagnoseDeclAvailability(TD, CurrentRange); } else if (const TypedefType *TD = dyn_cast(TyPtr)) { TypedefNameDecl *D = TD->getDecl(); - DiagnoseDeclAvailability(D, Range); + DiagnoseDeclAvailability(D, CurrentRange); } else if (const auto *ObjCO = dyn_cast(TyPtr)) { if (NamedDecl *D = ObjCO->getInterface()) - DiagnoseDeclAvailability(D, Range); + DiagnoseDeclAvailability(D, CurrentRange); } - return true; } Index: test/SemaObjC/unguarded-availability.m =================================================================== --- test/SemaObjC/unguarded-availability.m +++ test/SemaObjC/unguarded-availability.m @@ -135,6 +135,17 @@ func_10_12(); }; +AVAILABLE_10_12 +__attribute__((objc_root_class)) +@interface InterWithProp // expected-note 2 {{marked partial here}} +@property int x; +@end + +void test_property(void) { + int y = InterWithProp.x; // expected-warning{{'InterWithProp' is only available on macOS 10.12 or newer}} expected-note{{@available}} + InterWithProp.x = y; // expected-warning{{'InterWithProp' is only available on macOS 10.12 or newer}} expected-note{{@available}} +} + #ifdef OBJCPP int f(char) AVAILABLE_10_12;