diff options
Diffstat (limited to 'test/SemaObjC')
| -rw-r--r-- | test/SemaObjC/attr-availability.m | 30 | ||||
| -rw-r--r-- | test/SemaObjC/default-synthesize-3.m | 4 | ||||
| -rw-r--r-- | test/SemaObjC/default-synthesize.m | 2 | ||||
| -rw-r--r-- | test/SemaObjC/forward-protocol-incomplete-impl-warn.m | 2 | ||||
| -rw-r--r-- | test/SemaObjC/objc-container-subscripting-1.m | 5 | ||||
| -rw-r--r-- | test/SemaObjC/objc-container-subscripting-2.m | 19 | ||||
| -rw-r--r-- | test/SemaObjC/unguarded-availability-new.m | 8 | ||||
| -rw-r--r-- | test/SemaObjC/unguarded-availability.m | 59 |
8 files changed, 108 insertions, 21 deletions
diff --git a/test/SemaObjC/attr-availability.m b/test/SemaObjC/attr-availability.m index 02b7c5c81491..1245ac7409b8 100644 --- a/test/SemaObjC/attr-availability.m +++ b/test/SemaObjC/attr-availability.m @@ -13,7 +13,7 @@ @interface A <P> - (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note {{'method' has been explicitly marked deprecated here}} #if defined(WARN_PARTIAL) - // expected-note@+2 {{'partialMethod' has been explicitly marked partial here}} + // expected-note@+2 2 {{'partialMethod' has been explicitly marked partial here}} #endif - (void)partialMethod __attribute__((availability(macosx,introduced=10.8))); @@ -66,7 +66,10 @@ void f(A *a, B *b) { @end void f_after_redecl(A *a, B *b) { - [a partialMethod]; // no warning +#ifdef WARN_PARTIAL + // expected-warning@+2{{'partialMethod' is only available on macOS 10.8 or newer}} expected-note@+2 {{@available}} +#endif + [a partialMethod]; [b partialMethod]; // no warning [a partial_proto_method]; // no warning [b partial_proto_method]; // no warning @@ -133,6 +136,10 @@ id NSNibOwner, topNibObjects; @end @interface PartialI <PartialProt> +#ifdef WARN_PARTIAL +// expected-note@+3{{marked partial here}} +// expected-note@+3{{marked partial here}} +#endif - (void)partialMethod __attribute__((availability(macosx,introduced=10.8))); + (void)partialMethod __attribute__((availability(macosx,introduced=10.8))); @end @@ -160,14 +167,20 @@ id NSNibOwner, topNibObjects; @end void partialfun(PartialI* a) { - [a partialMethod]; // no warning +#ifdef WARN_PARTIAL + // expected-warning@+2 {{'partialMethod' is only available on macOS 10.8 or newer}} expected-note@+2{{@available}} +#endif + [a partialMethod]; [a ipartialMethod1]; // no warning #if defined(WARN_PARTIAL) // expected-warning@+2 {{'ipartialMethod2' is only available on macOS 10.8 or newer}} expected-note@+2 {{enclose 'ipartialMethod2' in an @available check to silence this warning}} #endif [a ipartialMethod2]; [a ppartialMethod]; // no warning - [PartialI partialMethod]; // no warning +#ifdef WARN_PARTIAL + // expected-warning@+2 {{'partialMethod' is only available on macOS 10.8 or newer}} expected-note@+2 {{@available}} +#endif + [PartialI partialMethod]; [PartialI ipartialMethod1]; // no warning #if defined(WARN_PARTIAL) // expected-warning@+2 {{'ipartialMethod2' is only available on macOS 10.8 or newer}} expected-note@+2 {{enclose 'ipartialMethod2' in an @available check to silence this warning}} @@ -177,20 +190,23 @@ void partialfun(PartialI* a) { } #if defined(WARN_PARTIAL) - // expected-note@+2 {{'PartialI2' has been explicitly marked partial here}} + // expected-note@+2 2 {{'PartialI2' has been explicitly marked partial here}} #endif __attribute__((availability(macosx, introduced = 10.8))) @interface PartialI2 @end #if defined(WARN_PARTIAL) - // expected-warning@+2 {{'PartialI2' is partial: introduced in macOS 10.8}} expected-note@+2 {{explicitly redeclare 'PartialI2' to silence this warning}} +// expected-warning@+2 {{'PartialI2' is partial: introduced in macOS 10.8}} expected-note@+2 {{annotate 'partialinter1' with an availability attribute to silence}} #endif void partialinter1(PartialI2* p) { } @class PartialI2; -void partialinter2(PartialI2* p) { // no warning +#ifdef WARN_PARTIAL +// expected-warning@+2 {{'PartialI2' is partial: introduced in macOS 10.8}} expected-note@+2 {{annotate 'partialinter2' with an availability attribute to silence}} +#endif +void partialinter2(PartialI2* p) { } diff --git a/test/SemaObjC/default-synthesize-3.m b/test/SemaObjC/default-synthesize-3.m index fe2b35f61523..9a05408aa060 100644 --- a/test/SemaObjC/default-synthesize-3.m +++ b/test/SemaObjC/default-synthesize-3.m @@ -173,13 +173,13 @@ typedef NSObject<Fooing> FooObject; @end @implementation Okay // expected-warning {{auto property synthesis will not synthesize property 'muahahaha' declared in protocol 'Fooing'}} expected-warning {{auto property synthesis will not synthesize property 'hoho' declared in protocol 'SubFooling'}} -@end +@end // expected-note 2 {{add a '@synthesize' directive}} @interface Fail : FooObject @end @implementation Fail // expected-warning {{auto property synthesis will not synthesize property 'muahahaha' declared in protocol 'Fooing'}} expected-warning {{auto property synthesis will not synthesize property 'hoho' declared in protocol 'SubFooling'}} -@end +@end // expected-note 2 {{add a '@synthesize' directive}} // rdar://16089191 @class NSURL; diff --git a/test/SemaObjC/default-synthesize.m b/test/SemaObjC/default-synthesize.m index 3f0ae0261daf..61ce9317c519 100644 --- a/test/SemaObjC/default-synthesize.m +++ b/test/SemaObjC/default-synthesize.m @@ -137,7 +137,7 @@ @end @implementation MyClass // expected-warning {{auto property synthesis will not synthesize property 'requiredString' declared in protocol 'MyProtocol'}} -@end +@end // expected-note {{add a '@synthesize' directive}} // rdar://18152478 @protocol NSObject @end diff --git a/test/SemaObjC/forward-protocol-incomplete-impl-warn.m b/test/SemaObjC/forward-protocol-incomplete-impl-warn.m index c235e32316a9..583bb4dd891d 100644 --- a/test/SemaObjC/forward-protocol-incomplete-impl-warn.m +++ b/test/SemaObjC/forward-protocol-incomplete-impl-warn.m @@ -17,4 +17,4 @@ @implementation IBImageCatalogDocument // expected-warning {{auto property synthesis will not synthesize property 'Prop' declared in protocol 'DVTInvalidation'}} \ // expected-warning {{method 'invalidate' in protocol 'DVTInvalidation' not implemented}} -@end +@end // expected-note {{add a '@synthesize' directive}} diff --git a/test/SemaObjC/objc-container-subscripting-1.m b/test/SemaObjC/objc-container-subscripting-1.m index a58a7c3bda81..b5ed5a68dd84 100644 --- a/test/SemaObjC/objc-container-subscripting-1.m +++ b/test/SemaObjC/objc-container-subscripting-1.m @@ -16,8 +16,7 @@ id oldObject = array[10]; // expected-warning {{instance method '-objectAtIndexe array[10] = 0; // expected-warning {{instance method '-setObject:atIndexedSubscript:' not found (return type defaults to 'id')}} id<P> p_array; -oldObject = p_array[10]; // expected-warning {{instance method '-objectAtIndexedSubscript:' not found (return type defaults to 'id')}} +oldObject = p_array[10]; // expected-error {{expected method to read array element not found on object of type 'id<P>'}} -p_array[10] = 0; // expected-warning {{instance method '-setObject:atIndexedSubscript:' not found (return type defaults to 'id')}} +p_array[10] = 0; // expected-error {{expected method to write array element not found on object of type 'id<P>'}} } - diff --git a/test/SemaObjC/objc-container-subscripting-2.m b/test/SemaObjC/objc-container-subscripting-2.m index 62320fcebb77..6e7ee7c40e58 100644 --- a/test/SemaObjC/objc-container-subscripting-2.m +++ b/test/SemaObjC/objc-container-subscripting-2.m @@ -28,3 +28,22 @@ void test_unused() { dict[array]; // expected-warning {{container access result unused - container access should not be used for side effects}} } +void testQualifiedId(id<P> qualifiedId) { + id object = qualifiedId[10]; // expected-error {{expected method to read array element not found on object of type 'id<P>'}} + qualifiedId[10] = qualifiedId; // expected-error {{expected method to write array element not found on object of type 'id<P>'}} +} + +void testUnqualifiedId(id unqualId) { + id object = unqualId[10]; + unqualId[10] = object; +} + +@protocol Subscriptable +- (id)objectAtIndexedSubscript:(size_t)index; +- (void)setObject:(id)object atIndexedSubscript:(size_t)index; +@end + +void testValidQualifiedId(id<Subscriptable> qualifiedId) { + id object = qualifiedId[10]; + qualifiedId[10] = object; +} diff --git a/test/SemaObjC/unguarded-availability-new.m b/test/SemaObjC/unguarded-availability-new.m index 33baedebc279..9c44b164d541 100644 --- a/test/SemaObjC/unguarded-availability-new.m +++ b/test/SemaObjC/unguarded-availability-new.m @@ -96,16 +96,16 @@ typedef int AVAILABLE_NEXT new_int; FUNC_AVAILABLE new_int x; #ifndef NO_WARNING #ifdef MAC - // expected-warning@-3 {{'new_int' is partial: introduced in macOS 10.14}} expected-note@-3 {{explicitly redeclare 'new_int' to silence this warning}} + // expected-warning@-3 {{'new_int' is partial: introduced in macOS 10.14}} expected-note@-3 {{annotate 'x' with an availability attribute to silence}} #endif #ifdef IOS - // expected-warning@-6 {{'new_int' is partial: introduced in iOS 12}} expected-note@-6 {{explicitly redeclare 'new_int' to silence this warning}} + // expected-warning@-6 {{'new_int' is partial: introduced in iOS 12}} expected-note@-6 {{annotate 'x' with an availability attribute to silence}} #endif #ifdef TVOS - // expected-warning@-9 {{'new_int' is partial: introduced in tvOS 13}} expected-note@-9 {{explicitly redeclare 'new_int' to silence this warning}} + // expected-warning@-9 {{'new_int' is partial: introduced in tvOS 13}} expected-note@-9 {{annotate 'x' with an availability attribute to silence}} #endif #ifdef WATCHOS - // expected-warning@-12 {{'new_int' is partial: introduced in watchOS 5}} expected-note@-12 {{explicitly redeclare 'new_int' to silence this warning}} + // expected-warning@-12 {{'new_int' is partial: introduced in watchOS 5}} expected-note@-12 {{annotate 'x' with an availability attribute to silence}} #endif #endif diff --git a/test/SemaObjC/unguarded-availability.m b/test/SemaObjC/unguarded-availability.m index 5febee038e3c..139b79158afe 100644 --- a/test/SemaObjC/unguarded-availability.m +++ b/test/SemaObjC/unguarded-availability.m @@ -5,6 +5,8 @@ #define AVAILABLE_10_11 __attribute__((availability(macos, introduced = 10.11))) #define AVAILABLE_10_12 __attribute__((availability(macos, introduced = 10.12))) +typedef int AVAILABLE_10_12 new_int; // expected-note + {{marked partial here}} + int func_10_11() AVAILABLE_10_11; // expected-note 4 {{'func_10_11' has been explicitly marked partial here}} #ifdef OBJCPP @@ -70,9 +72,9 @@ void use_typedef() { } __attribute__((objc_root_class)) -AVAILABLE_10_11 @interface Class_10_11 { +AVAILABLE_10_11 @interface Class_10_11 { // expected-note{{annotate 'Class_10_11' with an availability attribute to silence}} int_10_11 foo; - int_10_12 bar; // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{redeclare}} + int_10_12 bar; // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} } - (void)method1; - (void)method2; @@ -125,7 +127,7 @@ void test_blocks() { }; } -void test_params(int_10_12 x); // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{redeclare}} +void test_params(int_10_12 x); // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{annotate 'test_params' with an availability attribute to silence}} void test_params2(int_10_12 x) AVAILABLE_10_12; // no warn @@ -234,3 +236,54 @@ void functionInFunction() { } #endif + +struct InStruct { // expected-note{{annotate 'InStruct' with an availability attribute to silence}} + new_int mem; // expected-warning{{'new_int' is partial}} + + struct { new_int mem; } anon; // expected-warning{{'new_int' is partial}} expected-note{{annotate anonymous struct with an availability attribute}} +}; + +#ifdef OBJCPP +static constexpr int AVAILABLE_10_12 SomeConstexprValue = 2; // expected-note{{marked partial here}} +typedef enum { // expected-note{{annotate anonymous enum with an availability attribute}} + SomeValue = SomeConstexprValue // expected-warning{{'SomeConstexprValue' is partial}} +} SomeEnum; +#endif + +@interface InInterface +-(new_int)meth; // expected-warning{{'new_int' is partial}} expected-note{{annotate 'meth' with an availability attribute}} +@end + +@interface Proper // expected-note{{annotate 'Proper' with an availability attribute}} +@property (class) new_int x; // expected-warning{{'new_int' is partial}} +@end + +void with_local_struct() { + struct local { // expected-note{{annotate 'local' with an availability attribute}} + new_int x; // expected-warning{{'new_int' is partial}} + }; +} + +// rdar://33156429: +// Avoid the warning on protocol requirements. + +AVAILABLE_10_12 +@protocol NewProtocol // expected-note {{'NewProtocol' has been explicitly marked partial here}} +@end + +@protocol ProtocolWithNewProtocolRequirement <NewProtocol> // expected-note {{annotate 'ProtocolWithNewProtocolRequirement' with an availability attribute to silence}} + +@property(copy) id<NewProtocol> prop; // expected-warning {{'NewProtocol' is partial: introduced in macOS 10.12}} + +@end + +@interface BaseClass +@end + +@interface ClassWithNewProtocolRequirement : BaseClass <NewProtocol> + +@end + +@interface BaseClass (CategoryWithNewProtocolRequirement) <NewProtocol> + +@end |
