| // RUN: rm -rf %t | |
| // RUN: split-file %s %t | |
| // RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-map-file=%t/module.modulemap -I %t -x objective-c -emit-module -fmodule-name=MyLibrary %t/module.modulemap -o %t/MyLibrary-no-lsv.pcm -verify | |
| // RUN: %clang_cc1 -Wundeclared-selector -fmodules -fno-implicit-modules -fmodule-map-file=%t/module.modulemap -I %t -fmodule-file=MyLibrary=%t/MyLibrary-no-lsv.pcm %t/base.m -verify | |
| // RUN: %clang_cc1 -Wundeclared-selector -fmodules -fno-implicit-modules -fmodule-map-file=%t/module.modulemap -I %t -fmodule-file=MyLibrary=%t/MyLibrary-no-lsv.pcm %t/extras.m -verify | |
| // RUN: %clang_cc1 -Wundeclared-selector -fmodules -fno-implicit-modules -fmodule-map-file=%t/module.modulemap -I %t -fmodule-file=MyLibrary=%t/MyLibrary-no-lsv.pcm %t/module.m -verify | |
| // RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-map-file=%t/module.modulemap -fmodules-local-submodule-visibility -I %t -x objective-c -emit-module -fmodule-name=MyLibrary %t/module.modulemap -o %t/MyLibrary-lsv.pcm -verify | |
| // RUN: %clang_cc1 -Wundeclared-selector -fmodules -fno-implicit-modules -fmodule-map-file=%t/module.modulemap -fmodules-local-submodule-visibility -I %t -fmodule-file=MyLibrary=%t/MyLibrary-lsv.pcm -x objective-c -emit-module -fmodule-name=M %t/module.modulemap -o %t/M.pcm -verify | |
| // RUN: %clang_cc1 -Wundeclared-selector -fmodules -fno-implicit-modules -fmodule-map-file=%t/module.modulemap -fmodules-local-submodule-visibility -I %t -fmodule-file=MyLibrary=%t/MyLibrary-lsv.pcm -fmodule-file=M=%t/M.pcm %t/M.m -verify | |
| // RUN: %clang_cc1 -Wundeclared-selector -fmodules -fno-implicit-modules -fmodule-map-file=%t/module.modulemap -fmodules-local-submodule-visibility -I %t -fmodule-file=MyLibrary=%t/MyLibrary-lsv.pcm -fmodule-file=M=%t/M.pcm %t/A.m -verify | |
| // RUN: %clang_cc1 -Wundeclared-selector -fmodules -fno-implicit-modules -fmodule-map-file=%t/module.modulemap -fmodules-local-submodule-visibility -I %t -fmodule-file=MyLibrary=%t/MyLibrary-lsv.pcm -fmodule-file=M=%t/M.pcm %t/B.m -verify | |
| //--- module.modulemap | |
| module MyLibrary { | |
| module MyObject { | |
| header "MyObject.h" | |
| export * | |
| } | |
| module Extras { | |
| header "MyObject+Extras.h" | |
| export * | |
| } | |
| } | |
| module M { | |
| // Imports MyObject+Extras.h | |
| module A { | |
| header "A.h" | |
| export * | |
| } | |
| // Only imports MyObject.h. Without LSV, the extras will | |
| // leak in from submodule A. But with LSV, only the base | |
| // methods will be visible, as would be the case when | |
| // B.h was included by itself without modules. | |
| module B { | |
| header "B.h" | |
| export * | |
| } | |
| } | |
| //--- MyObject.h | |
| // expected-no-diagnostics | |
| @protocol BaseProtocol | |
| @property int baseProtocolProperty; | |
| - (void)baseProtocolMethod; | |
| + (void)baseProtocolClassMethod; | |
| @end | |
| @protocol SubProtocol <BaseProtocol> | |
| - (void)subProtocolMethod; | |
| + (void)subProtocolClassMethod; | |
| @end | |
| @interface MyObject <SubProtocol> { | |
| @public | |
| int interfaceIvar; | |
| } | |
| @property int interfaceProperty; | |
| @property (class) int interfaceClassProperty; | |
| @property (readonly) int redeclaredProperty; | |
| - (void)interfaceMethod; | |
| + (void)interfaceClassMethod; | |
| @end | |
| @interface MyObject (MyObject) | |
| @property int categoryProperty; | |
| @property (class) int categoryClassProperty; | |
| - (void)categoryMethod; | |
| + (void)categoryClassMethod; | |
| @end | |
| //--- MyObject+Extras.h | |
| #import <MyObject.h> | |
| @protocol ExtraProtocol | |
| @property int extraProtocolProperty; | |
| - (void)extraProtocolMethod; | |
| + (void)extraProtocolClassMethod; | |
| @end | |
| @interface MyObject (Category) <ExtraProtocol> | |
| @property int extraCategoryProperty; | |
| @property (class) int extraCategoryClassProperty; | |
| - (void)extraCategoryMethod; | |
| + (void)extraCategoryClassMethod; | |
| @end | |
| @interface MyObject () { | |
| @public | |
| int extensionIvar; | |
| } | |
| @property int extensionProperty; | |
| @property (class) int extensionClassProperty; | |
| @property (readwrite) int redeclaredProperty; | |
| - (instancetype)initWithInt:(int)value __attribute__((objc_designated_initializer)); | |
| - (void)extensionMethod; | |
| + (void)extensionClassMethod; | |
| @end | |
| //--- A.h | |
| #import <MyObject+Extras.h> | |
| static inline void test_typed_instance_A(MyObject *object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; | |
| [object extensionMethod]; | |
| object.interfaceProperty = 0; | |
| object.categoryProperty = 0; | |
| object.extraCategoryProperty = 0; | |
| object.extensionProperty = 0; | |
| object.redeclaredProperty = 0; | |
| object->interfaceIvar = 0; | |
| object->extensionIvar = 0; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| object.extraProtocolProperty = 0; | |
| } | |
| static inline void test_typed_class_A(void) { | |
| [MyObject interfaceClassMethod]; | |
| [MyObject categoryClassMethod]; | |
| [MyObject extraCategoryClassMethod]; | |
| [MyObject extensionClassMethod]; | |
| MyObject.interfaceClassProperty = 0; | |
| MyObject.categoryClassProperty = 0; | |
| MyObject.extraCategoryClassProperty = 0; | |
| MyObject.extensionClassProperty = 0; | |
| [MyObject baseProtocolClassMethod]; | |
| [MyObject subProtocolClassMethod]; | |
| [MyObject extraProtocolClassMethod]; | |
| } | |
| static inline void test_id_A(id object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; | |
| [object extensionMethod]; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; | |
| } | |
| static inline void test_class_A(Class cls) { | |
| [cls interfaceClassMethod]; | |
| [cls categoryClassMethod]; | |
| [cls extraCategoryClassMethod]; | |
| [cls extensionClassMethod]; | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| [cls extraProtocolClassMethod]; | |
| } | |
| static inline void test_selector_A(void) { | |
| SEL selectors[] = { | |
| @selector(interfaceMethod), | |
| @selector(categoryMethod), | |
| @selector(extraCategoryMethod), | |
| @selector(extensionMethod), | |
| @selector(interfaceClassMethod), | |
| @selector(categoryClassMethod), | |
| @selector(extraCategoryClassMethod), | |
| @selector(extensionClassMethod), | |
| @selector(baseProtocolMethod), | |
| @selector(subProtocolMethod), | |
| @selector(extraProtocolMethod), | |
| @selector(baseProtocolClassMethod), | |
| @selector(subProtocolClassMethod), | |
| @selector(extraProtocolClassMethod), | |
| }; | |
| } | |
| static inline void test_qualified_id_A(id<SubProtocol> object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| } | |
| static inline void test_qualified_class_A(Class<SubProtocol> cls) { | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| } | |
| @interface LocalObject_A <SubProtocol> | |
| @end | |
| static inline void test_conformance_A(LocalObject_A *object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| } | |
| //--- B.h | |
| #import <MyObject.h> | |
| static inline void test_typed_instance_B(MyObject *object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; // expected-warning {{instance method '-extraCategoryMethod' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| [object extensionMethod]; // expected-warning {{instance method '-extensionMethod' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| object.interfaceProperty = 0; | |
| object.categoryProperty = 0; | |
| object->interfaceIvar = 0; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; // expected-warning {{instance method '-extraProtocolMethod' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| object.baseProtocolProperty = 0; | |
| } | |
| static inline void test_typed_class_B(void) { | |
| [MyObject interfaceClassMethod]; | |
| [MyObject categoryClassMethod]; | |
| [MyObject extraCategoryClassMethod]; // expected-warning {{class method '+extraCategoryClassMethod' not found}} | |
| [MyObject extensionClassMethod]; // expected-warning {{class method '+extensionClassMethod' not found}} | |
| MyObject.interfaceClassProperty = 0; | |
| MyObject.categoryClassProperty = 0; | |
| [MyObject baseProtocolClassMethod]; | |
| [MyObject subProtocolClassMethod]; | |
| [MyObject extraProtocolClassMethod]; // expected-warning {{class method '+extraProtocolClassMethod' not found}} | |
| } | |
| static inline void test_id_B(id object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; // expected-warning {{instance method '-extraCategoryMethod' not found}} | |
| [object extensionMethod]; // expected-warning {{instance method '-extensionMethod' not found}} | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; // expected-warning {{instance method '-extraProtocolMethod' not found}} | |
| } | |
| static inline void test_class_B(Class cls) { | |
| [cls interfaceClassMethod]; | |
| [cls categoryClassMethod]; | |
| [cls extraCategoryClassMethod]; // expected-warning {{class method '+extraCategoryClassMethod' not found}} | |
| [cls extensionClassMethod]; // expected-warning {{class method '+extensionClassMethod' not found}} | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| [cls extraProtocolClassMethod]; // expected-warning {{class method '+extraProtocolClassMethod' not found}} | |
| } | |
| static inline void test_selector_B(void) { | |
| SEL selectors[] = { | |
| @selector(interfaceMethod), | |
| @selector(categoryMethod), | |
| @selector(extraCategoryMethod), // expected-warning {{undeclared selector 'extraCategoryMethod'}} | |
| @selector(extensionMethod), // expected-warning {{undeclared selector 'extensionMethod'}} | |
| @selector(interfaceClassMethod), | |
| @selector(categoryClassMethod), | |
| @selector(extraCategoryClassMethod), // expected-warning {{undeclared selector 'extraCategoryClassMethod'}} | |
| @selector(extensionClassMethod), // expected-warning {{undeclared selector 'extensionClassMethod'}} | |
| @selector(baseProtocolMethod), | |
| @selector(subProtocolMethod), | |
| @selector(extraProtocolMethod), // expected-warning {{undeclared selector 'extraProtocolMethod'}} | |
| @selector(baseProtocolClassMethod), | |
| @selector(subProtocolClassMethod), | |
| @selector(extraProtocolClassMethod), // expected-warning {{undeclared selector 'extraProtocolClassMethod'}} | |
| }; | |
| } | |
| static inline void test_qualified_id_B(id<SubProtocol> object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| } | |
| static inline void test_qualified_class_B(Class<SubProtocol> cls) { | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| } | |
| @interface LocalObject_B <SubProtocol> | |
| @end | |
| static inline void test_conformance_B(LocalObject_B *object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| } | |
| //--- base.m | |
| #import <MyObject.h> | |
| @interface Subclass : MyObject | |
| - (instancetype)initWithSubclassInt:(int)value __attribute__((objc_designated_initializer)); // #initWithSubclassInt | |
| @end | |
| @implementation Subclass | |
| - (instancetype)initWithSubclassInt:(int)value { // expected-warning {{designated initializer missing a 'super' call to a designated initializer of the super class}} | |
| // expected-note@#initWithSubclassInt {{method marked as designated initializer of the class here}} | |
| return [super initWithInt:value]; // expected-warning {{instance method '-initWithInt:' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| } | |
| @end | |
| void test_typed_instance(MyObject *object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; // expected-warning {{instance method '-extraCategoryMethod' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| [object extensionMethod]; // expected-warning {{instance method '-extensionMethod' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| object.interfaceProperty = 0; | |
| object.categoryProperty = 0; | |
| object.extraCategoryProperty = 0; // expected-error {{property 'extraCategoryProperty' not found on object of type 'MyObject *'}} | |
| // expected-note@MyObject.h:* {{'categoryProperty' declared here}} | |
| object.extensionProperty = 0; // expected-error {{property 'extensionProperty' not found on object of type 'MyObject *'}} | |
| object.redeclaredProperty = 0; // expected-error {{assignment to readonly property}} | |
| object->interfaceIvar = 0; | |
| object->extensionIvar = 0; // expected-error {{'MyObject' does not have a member named 'extensionIvar'}} | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; // expected-warning {{instance method '-extraProtocolMethod' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| object.baseProtocolProperty = 0; | |
| object.extraProtocolProperty = 0; // expected-error {{property 'extraProtocolProperty' not found on object of type 'MyObject *'}} | |
| // expected-note@MyObject.h:* {{'baseProtocolProperty' declared here}} | |
| } | |
| void test_typed_class(void) { | |
| [MyObject interfaceClassMethod]; | |
| [MyObject categoryClassMethod]; | |
| [MyObject extraCategoryClassMethod]; // expected-warning {{class method '+extraCategoryClassMethod' not found}} | |
| [MyObject extensionClassMethod]; // expected-warning {{class method '+extensionClassMethod' not found}} | |
| MyObject.interfaceClassProperty = 0; | |
| MyObject.categoryClassProperty = 0; | |
| MyObject.extraCategoryClassProperty = 0; // expected-error {{property 'extraCategoryClassProperty' not found on object of type 'MyObject'}} | |
| MyObject.extensionClassProperty = 0; // expected-error {{property 'extensionClassProperty' not found on object of type 'MyObject'}} | |
| [MyObject baseProtocolClassMethod]; | |
| [MyObject subProtocolClassMethod]; | |
| [MyObject extraProtocolClassMethod]; // expected-warning {{class method '+extraProtocolClassMethod' not found}} | |
| } | |
| void test_id(id object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; // expected-warning {{instance method '-extraCategoryMethod' not found}} | |
| [object extensionMethod]; // expected-warning {{instance method '-extensionMethod' not found}} | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; // expected-warning {{instance method '-extraProtocolMethod' not found}} | |
| } | |
| void test_class(Class cls) { | |
| [cls interfaceClassMethod]; | |
| [cls categoryClassMethod]; | |
| [cls extraCategoryClassMethod]; // expected-warning {{class method '+extraCategoryClassMethod' not found}} | |
| [cls extensionClassMethod]; // expected-warning {{class method '+extensionClassMethod' not found}} | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| [cls extraProtocolClassMethod]; // expected-warning {{class method '+extraProtocolClassMethod' not found}} | |
| } | |
| void test_selector(void) { | |
| SEL selectors[] = { | |
| @selector(interfaceMethod), | |
| @selector(categoryMethod), | |
| @selector(extraCategoryMethod), // expected-warning {{undeclared selector 'extraCategoryMethod'}} | |
| @selector(extensionMethod), // expected-warning {{undeclared selector 'extensionMethod'}} | |
| @selector(interfaceClassMethod), | |
| @selector(categoryClassMethod), | |
| @selector(extraCategoryClassMethod), // expected-warning {{undeclared selector 'extraCategoryClassMethod'}} | |
| @selector(extensionClassMethod), // expected-warning {{undeclared selector 'extensionClassMethod'}} | |
| @selector(baseProtocolMethod), | |
| @selector(subProtocolMethod), | |
| @selector(extraProtocolMethod), // expected-warning {{undeclared selector 'extraProtocolMethod'}} | |
| @selector(baseProtocolClassMethod), | |
| @selector(subProtocolClassMethod), | |
| @selector(extraProtocolClassMethod), // expected-warning {{undeclared selector 'extraProtocolClassMethod'}} | |
| }; | |
| } | |
| void test_qualified_id(id<SubProtocol> object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| } | |
| void test_qualified_class(Class<SubProtocol> cls) { | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| } | |
| @interface LocalObject <SubProtocol> | |
| @end | |
| void test_conformance(LocalObject *object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| } | |
| //--- extras.m | |
| #import <MyObject+Extras.h> | |
| @interface Subclass : MyObject | |
| - (instancetype)initWithSubclassInt:(int)value __attribute__((objc_designated_initializer)); | |
| @end | |
| @implementation Subclass // expected-warning {{method override for the designated initializer of the superclass '-initWithInt:' not found}} | |
| // expected-note@MyObject+Extras.h:* {{method marked as designated initializer of the class here}} | |
| - (instancetype)initWithSubclassInt:(int)value { | |
| return [super initWithInt:value]; | |
| } | |
| @end | |
| void test_typed_instance(MyObject *object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; | |
| [object extensionMethod]; | |
| object.interfaceProperty = 0; | |
| object.categoryProperty = 0; | |
| object.extraCategoryProperty = 0; | |
| object.extensionProperty = 0; | |
| object.redeclaredProperty = 0; | |
| object->interfaceIvar = 0; | |
| object->extensionIvar = 0; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| object.extraProtocolProperty = 0; | |
| } | |
| void test_typed_class(void) { | |
| [MyObject interfaceClassMethod]; | |
| [MyObject categoryClassMethod]; | |
| [MyObject extraCategoryClassMethod]; | |
| [MyObject extensionClassMethod]; | |
| MyObject.interfaceClassProperty = 0; | |
| MyObject.categoryClassProperty = 0; | |
| MyObject.extraCategoryClassProperty = 0; | |
| MyObject.extensionClassProperty = 0; | |
| [MyObject baseProtocolClassMethod]; | |
| [MyObject subProtocolClassMethod]; | |
| [MyObject extraProtocolClassMethod]; | |
| } | |
| void test_id(id object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; | |
| [object extensionMethod]; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; | |
| } | |
| void test_class(Class cls) { | |
| [cls interfaceClassMethod]; | |
| [cls categoryClassMethod]; | |
| [cls extraCategoryClassMethod]; | |
| [cls extensionClassMethod]; | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| [cls extraProtocolClassMethod]; | |
| } | |
| void test_selector(void) { | |
| SEL selectors[] = { | |
| @selector(interfaceMethod), | |
| @selector(categoryMethod), | |
| @selector(extraCategoryMethod), | |
| @selector(extensionMethod), | |
| @selector(interfaceClassMethod), | |
| @selector(categoryClassMethod), | |
| @selector(extraCategoryClassMethod), | |
| @selector(extensionClassMethod), | |
| @selector(baseProtocolMethod), | |
| @selector(subProtocolMethod), | |
| @selector(extraProtocolMethod), | |
| @selector(baseProtocolClassMethod), | |
| @selector(subProtocolClassMethod), | |
| @selector(extraProtocolClassMethod), | |
| }; | |
| } | |
| void test_qualified_id(id<SubProtocol> object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| } | |
| void test_qualified_class(Class<SubProtocol> cls) { | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| } | |
| @interface LocalObject <SubProtocol> | |
| @end | |
| void test_conformance(LocalObject *object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| } | |
| //--- module.m | |
| @import MyLibrary; | |
| @interface Subclass : MyObject | |
| - (instancetype)initWithSubclassInt:(int)value __attribute__((objc_designated_initializer)); | |
| @end | |
| @implementation Subclass // expected-warning {{method override for the designated initializer of the superclass '-initWithInt:' not found}} | |
| // expected-note@MyObject+Extras.h:* {{method marked as designated initializer of the class here}} | |
| - (instancetype)initWithSubclassInt:(int)value { | |
| return [super initWithInt:value]; | |
| } | |
| @end | |
| void test_typed_instance(MyObject *object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; | |
| [object extensionMethod]; | |
| object.interfaceProperty = 0; | |
| object.categoryProperty = 0; | |
| object.extraCategoryProperty = 0; | |
| object.extensionProperty = 0; | |
| object.redeclaredProperty = 0; | |
| object->interfaceIvar = 0; | |
| object->extensionIvar = 0; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| object.extraProtocolProperty = 0; | |
| } | |
| void test_typed_class(void) { | |
| [MyObject interfaceClassMethod]; | |
| [MyObject categoryClassMethod]; | |
| [MyObject extraCategoryClassMethod]; | |
| [MyObject extensionClassMethod]; | |
| MyObject.interfaceClassProperty = 0; | |
| MyObject.categoryClassProperty = 0; | |
| MyObject.extraCategoryClassProperty = 0; | |
| MyObject.extensionClassProperty = 0; | |
| [MyObject baseProtocolClassMethod]; | |
| [MyObject subProtocolClassMethod]; | |
| [MyObject extraProtocolClassMethod]; | |
| } | |
| void test_id(id object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; | |
| [object extensionMethod]; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; | |
| } | |
| void test_class(Class cls) { | |
| [cls interfaceClassMethod]; | |
| [cls categoryClassMethod]; | |
| [cls extraCategoryClassMethod]; | |
| [cls extensionClassMethod]; | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| [cls extraProtocolClassMethod]; | |
| } | |
| void test_selector(void) { | |
| SEL selectors[] = { | |
| @selector(interfaceMethod), | |
| @selector(categoryMethod), | |
| @selector(extraCategoryMethod), | |
| @selector(extensionMethod), | |
| @selector(interfaceClassMethod), | |
| @selector(categoryClassMethod), | |
| @selector(extraCategoryClassMethod), | |
| @selector(extensionClassMethod), | |
| @selector(baseProtocolMethod), | |
| @selector(subProtocolMethod), | |
| @selector(extraProtocolMethod), | |
| @selector(baseProtocolClassMethod), | |
| @selector(subProtocolClassMethod), | |
| @selector(extraProtocolClassMethod), | |
| }; | |
| } | |
| void test_qualified_id(id<SubProtocol> object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| } | |
| void test_qualified_class(Class<SubProtocol> cls) { | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| } | |
| @interface LocalObject <SubProtocol> | |
| @end | |
| void test_conformance(LocalObject *object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| } | |
| //--- M.m | |
| @import M; | |
| @interface Subclass : MyObject | |
| - (instancetype)initWithSubclassInt:(int)value __attribute__((objc_designated_initializer)); | |
| @end | |
| @implementation Subclass // expected-warning {{method override for the designated initializer of the superclass '-initWithInt:' not found}} | |
| // expected-note@MyObject+Extras.h:* {{method marked as designated initializer of the class here}} | |
| - (instancetype)initWithSubclassInt:(int)value { | |
| return [super initWithInt:value]; | |
| } | |
| @end | |
| void test_typed_instance(MyObject *object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; | |
| [object extensionMethod]; | |
| object.interfaceProperty = 0; | |
| object.categoryProperty = 0; | |
| object.extraCategoryProperty = 0; | |
| object.extensionProperty = 0; | |
| object.redeclaredProperty = 0; | |
| object->interfaceIvar = 0; | |
| object->extensionIvar = 0; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| object.extraProtocolProperty = 0; | |
| } | |
| void test_typed_class(void) { | |
| [MyObject interfaceClassMethod]; | |
| [MyObject categoryClassMethod]; | |
| [MyObject extraCategoryClassMethod]; | |
| [MyObject extensionClassMethod]; | |
| MyObject.interfaceClassProperty = 0; | |
| MyObject.categoryClassProperty = 0; | |
| MyObject.extraCategoryClassProperty = 0; | |
| MyObject.extensionClassProperty = 0; | |
| [MyObject baseProtocolClassMethod]; | |
| [MyObject subProtocolClassMethod]; | |
| [MyObject extraProtocolClassMethod]; | |
| } | |
| void test_id(id object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; | |
| [object extensionMethod]; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; | |
| } | |
| void test_class(Class cls) { | |
| [cls interfaceClassMethod]; | |
| [cls categoryClassMethod]; | |
| [cls extraCategoryClassMethod]; | |
| [cls extensionClassMethod]; | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| [cls extraProtocolClassMethod]; | |
| } | |
| void test_selector(void) { | |
| SEL selectors[] = { | |
| @selector(interfaceMethod), | |
| @selector(categoryMethod), | |
| @selector(extraCategoryMethod), | |
| @selector(extensionMethod), | |
| @selector(interfaceClassMethod), | |
| @selector(categoryClassMethod), | |
| @selector(extraCategoryClassMethod), | |
| @selector(extensionClassMethod), | |
| @selector(baseProtocolMethod), | |
| @selector(subProtocolMethod), | |
| @selector(extraProtocolMethod), | |
| @selector(baseProtocolClassMethod), | |
| @selector(subProtocolClassMethod), | |
| @selector(extraProtocolClassMethod), | |
| }; | |
| } | |
| void test_qualified_id(id<SubProtocol> object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| } | |
| void test_qualified_class(Class<SubProtocol> cls) { | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| } | |
| @interface LocalObject <SubProtocol> | |
| @end | |
| void test_conformance(LocalObject *object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| } | |
| //--- A.m | |
| #import <A.h> | |
| @interface Subclass : MyObject | |
| - (instancetype)initWithSubclassInt:(int)value __attribute__((objc_designated_initializer)); | |
| @end | |
| @implementation Subclass // expected-warning {{method override for the designated initializer of the superclass '-initWithInt:' not found}} | |
| // expected-note@MyObject+Extras.h:* {{method marked as designated initializer of the class here}} | |
| - (instancetype)initWithSubclassInt:(int)value { | |
| return [super initWithInt:value]; | |
| } | |
| @end | |
| void test_typed_instance(MyObject *object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; | |
| [object extensionMethod]; | |
| object.interfaceProperty = 0; | |
| object.categoryProperty = 0; | |
| object.extraCategoryProperty = 0; | |
| object.extensionProperty = 0; | |
| object.redeclaredProperty = 0; | |
| object->interfaceIvar = 0; | |
| object->extensionIvar = 0; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| object.extraProtocolProperty = 0; | |
| } | |
| void test_typed_class(void) { | |
| [MyObject interfaceClassMethod]; | |
| [MyObject categoryClassMethod]; | |
| [MyObject extraCategoryClassMethod]; | |
| [MyObject extensionClassMethod]; | |
| MyObject.interfaceClassProperty = 0; | |
| MyObject.categoryClassProperty = 0; | |
| MyObject.extraCategoryClassProperty = 0; | |
| MyObject.extensionClassProperty = 0; | |
| [MyObject baseProtocolClassMethod]; | |
| [MyObject subProtocolClassMethod]; | |
| [MyObject extraProtocolClassMethod]; | |
| } | |
| void test_id(id object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; | |
| [object extensionMethod]; | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; | |
| } | |
| void test_class(Class cls) { | |
| [cls interfaceClassMethod]; | |
| [cls categoryClassMethod]; | |
| [cls extraCategoryClassMethod]; | |
| [cls extensionClassMethod]; | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| [cls extraProtocolClassMethod]; | |
| } | |
| void test_selector(void) { | |
| SEL selectors[] = { | |
| @selector(interfaceMethod), | |
| @selector(categoryMethod), | |
| @selector(extraCategoryMethod), | |
| @selector(extensionMethod), | |
| @selector(interfaceClassMethod), | |
| @selector(categoryClassMethod), | |
| @selector(extraCategoryClassMethod), | |
| @selector(extensionClassMethod), | |
| @selector(baseProtocolMethod), | |
| @selector(subProtocolMethod), | |
| @selector(extraProtocolMethod), | |
| @selector(baseProtocolClassMethod), | |
| @selector(subProtocolClassMethod), | |
| @selector(extraProtocolClassMethod), | |
| }; | |
| } | |
| void test_qualified_id(id<SubProtocol> object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| } | |
| void test_qualified_class(Class<SubProtocol> cls) { | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| } | |
| @interface LocalObject <SubProtocol> | |
| @end | |
| void test_conformance(LocalObject *object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| } | |
| //--- B.m | |
| #import <B.h> | |
| @interface Subclass : MyObject | |
| - (instancetype)initWithSubclassInt:(int)value __attribute__((objc_designated_initializer)); // #initWithSubclassInt | |
| @end | |
| @implementation Subclass | |
| - (instancetype)initWithSubclassInt:(int)value { // expected-warning {{designated initializer missing a 'super' call to a designated initializer of the super class}} | |
| // expected-note@#initWithSubclassInt {{method marked as designated initializer of the class here}} | |
| return [super initWithInt:value]; // expected-warning {{instance method '-initWithInt:' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| } | |
| @end | |
| void test_typed_instance(MyObject *object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; // expected-warning {{instance method '-extraCategoryMethod' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| [object extensionMethod]; // expected-warning {{instance method '-extensionMethod' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| object.interfaceProperty = 0; | |
| object.categoryProperty = 0; | |
| object.extraCategoryProperty = 0; // expected-error {{property 'extraCategoryProperty' not found on object of type 'MyObject *'}} | |
| // expected-note@MyObject.h:* {{'categoryProperty' declared here}} | |
| object.extensionProperty = 0; // expected-error {{property 'extensionProperty' not found on object of type 'MyObject *'}} | |
| object.redeclaredProperty = 0; // expected-error {{assignment to readonly property}} | |
| object->interfaceIvar = 0; | |
| object->extensionIvar = 0; // expected-error {{'MyObject' does not have a member named 'extensionIvar'}} | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; // expected-warning {{instance method '-extraProtocolMethod' not found}} | |
| // expected-note@MyObject.h:* {{receiver is instance of class declared here}} | |
| object.baseProtocolProperty = 0; | |
| object.extraProtocolProperty = 0; // expected-error {{property 'extraProtocolProperty' not found on object of type 'MyObject *'}} | |
| // expected-note@MyObject.h:* {{'baseProtocolProperty' declared here}} | |
| } | |
| void test_typed_class(void) { | |
| [MyObject interfaceClassMethod]; | |
| [MyObject categoryClassMethod]; | |
| [MyObject extraCategoryClassMethod]; // expected-warning {{class method '+extraCategoryClassMethod' not found}} | |
| [MyObject extensionClassMethod]; // expected-warning {{class method '+extensionClassMethod' not found}} | |
| MyObject.interfaceClassProperty = 0; | |
| MyObject.categoryClassProperty = 0; | |
| MyObject.extraCategoryClassProperty = 0; // expected-error {{property 'extraCategoryClassProperty' not found on object of type 'MyObject'}} | |
| MyObject.extensionClassProperty = 0; // expected-error {{property 'extensionClassProperty' not found on object of type 'MyObject'}} | |
| [MyObject baseProtocolClassMethod]; | |
| [MyObject subProtocolClassMethod]; | |
| [MyObject extraProtocolClassMethod]; // expected-warning {{class method '+extraProtocolClassMethod' not found}} | |
| } | |
| void test_id(id object) { | |
| [object interfaceMethod]; | |
| [object categoryMethod]; | |
| [object extraCategoryMethod]; // expected-warning {{instance method '-extraCategoryMethod' not found}} | |
| [object extensionMethod]; // expected-warning {{instance method '-extensionMethod' not found}} | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| [object extraProtocolMethod]; // expected-warning {{instance method '-extraProtocolMethod' not found}} | |
| } | |
| void test_class(Class cls) { | |
| [cls interfaceClassMethod]; | |
| [cls categoryClassMethod]; | |
| [cls extraCategoryClassMethod]; // expected-warning {{class method '+extraCategoryClassMethod' not found}} | |
| [cls extensionClassMethod]; // expected-warning {{class method '+extensionClassMethod' not found}} | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| [cls extraProtocolClassMethod]; // expected-warning {{class method '+extraProtocolClassMethod' not found}} | |
| } | |
| void test_selector(void) { | |
| SEL selectors[] = { | |
| @selector(interfaceMethod), | |
| @selector(categoryMethod), | |
| @selector(extraCategoryMethod), // expected-warning {{undeclared selector 'extraCategoryMethod'}} | |
| @selector(extensionMethod), // expected-warning {{undeclared selector 'extensionMethod'}} | |
| @selector(interfaceClassMethod), | |
| @selector(categoryClassMethod), | |
| @selector(extraCategoryClassMethod), // expected-warning {{undeclared selector 'extraCategoryClassMethod'}} | |
| @selector(extensionClassMethod), // expected-warning {{undeclared selector 'extensionClassMethod'}} | |
| @selector(baseProtocolMethod), | |
| @selector(subProtocolMethod), | |
| @selector(extraProtocolMethod), // expected-warning {{undeclared selector 'extraProtocolMethod'}} | |
| @selector(baseProtocolClassMethod), | |
| @selector(subProtocolClassMethod), | |
| @selector(extraProtocolClassMethod), // expected-warning {{undeclared selector 'extraProtocolClassMethod'}} | |
| }; | |
| } | |
| void test_qualified_id(id<SubProtocol> object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| object.baseProtocolProperty = 0; | |
| } | |
| void test_qualified_class(Class<SubProtocol> cls) { | |
| [cls baseProtocolClassMethod]; | |
| [cls subProtocolClassMethod]; | |
| } | |
| @interface LocalObject <SubProtocol> | |
| @end | |
| void test_conformance(LocalObject *object) { | |
| [object baseProtocolMethod]; | |
| [object subProtocolMethod]; | |
| } |