diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 9 | ||||
-rw-r--r-- | clang/test/SemaObjC/unguarded-availability.m | 20 |
2 files changed, 29 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 1cac2a98796..32be26efa14 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -7258,6 +7258,12 @@ public: bool TraverseLambdaExpr(LambdaExpr *E) { return true; } + bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) { + if (PRE->isClassReceiver()) + DiagnoseDeclAvailability(PRE->getClassReceiver(), PRE->getReceiverLocation()); + return true; + } + bool VisitObjCMessageExpr(ObjCMessageExpr *Msg) { if (ObjCMethodDecl *D = Msg->getMethodDecl()) DiagnoseDeclAvailability( @@ -7387,6 +7393,9 @@ bool DiagnoseUnguardedAvailability::VisitTypeLoc(TypeLoc Ty) { const Type *TyPtr = Ty.getTypePtr(); SourceRange Range{Ty.getBeginLoc(), Ty.getEndLoc()}; + if (Range.isInvalid()) + return true; + if (const TagType *TT = dyn_cast<TagType>(TyPtr)) { TagDecl *TD = TT->getDecl(); DiagnoseDeclAvailability(TD, Range); diff --git a/clang/test/SemaObjC/unguarded-availability.m b/clang/test/SemaObjC/unguarded-availability.m index 071a21ea1b3..82823204ba6 100644 --- a/clang/test/SemaObjC/unguarded-availability.m +++ b/clang/test/SemaObjC/unguarded-availability.m @@ -135,6 +135,26 @@ void (^topLevelBlockDecl)() = ^ { func_10_12(); }; +AVAILABLE_10_12 +__attribute__((objc_root_class)) +@interface InterWithProp // expected-note 2 {{marked partial here}} +@property(class) int x; ++ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{marked partial here}} +@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}} expected-warning{{'setX:' is only available on macOS 10.12 or newer}} expected-note{{@available}} +} + +__attribute__((objc_root_class)) +@interface Subscriptable +- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // expected-note{{marked partial here}} +@end + +void test_at(Subscriptable *x) { + id y = x[42]; // expected-warning{{'objectAtIndexedSubscript:' is only available on macOS 10.12 or newer}} expected-note{{@available}} +} + #ifdef OBJCPP int f(char) AVAILABLE_10_12; |