2011-11-16 23:22:03 +08:00
|
|
|
// RUN: rm -rf %t
|
2013-02-08 03:01:24 +08:00
|
|
|
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_top -emit-module %S/Inputs/module.map
|
|
|
|
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_left -emit-module %S/Inputs/module.map
|
|
|
|
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.map
|
|
|
|
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.map
|
|
|
|
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_other -emit-module %S/Inputs/module.map
|
|
|
|
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -verify
|
2011-09-01 08:58:55 +08:00
|
|
|
|
2012-12-12 06:11:52 +08:00
|
|
|
@import category_bottom;
|
2011-09-01 08:58:55 +08:00
|
|
|
|
|
|
|
|
2012-01-27 09:47:08 +08:00
|
|
|
|
|
|
|
|
2011-11-16 23:22:03 +08:00
|
|
|
// in category_left.h: expected-note {{previous definition}}
|
2012-08-10 09:06:16 +08:00
|
|
|
// in category_right.h: expected-warning@11 {{duplicate definition of category}}
|
2011-09-01 08:58:55 +08:00
|
|
|
|
|
|
|
@interface Foo(Source)
|
2011-11-16 23:22:03 +08:00
|
|
|
-(void)source;
|
2011-09-01 08:58:55 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
void test(Foo *foo, LeftFoo *leftFoo) {
|
|
|
|
[foo source];
|
|
|
|
[foo bottom];
|
|
|
|
[foo left];
|
|
|
|
[foo right1];
|
|
|
|
[foo right2];
|
|
|
|
[foo top];
|
2012-01-27 09:47:08 +08:00
|
|
|
[foo top2];
|
|
|
|
[foo top3];
|
2011-09-01 08:58:55 +08:00
|
|
|
|
|
|
|
[leftFoo left];
|
|
|
|
[leftFoo bottom];
|
|
|
|
}
|
2012-01-27 09:47:08 +08:00
|
|
|
|
|
|
|
// Load another module that also adds categories to Foo, verify that
|
|
|
|
// we see those categories.
|
2012-12-12 06:11:52 +08:00
|
|
|
@import category_other;
|
2012-01-27 09:47:08 +08:00
|
|
|
|
|
|
|
void test_other(Foo *foo) {
|
|
|
|
[foo other];
|
|
|
|
}
|
2013-01-17 07:00:23 +08:00
|
|
|
|
|
|
|
// Make sure we don't see categories that should be hidden
|
|
|
|
void test_hidden_all_errors(Foo *foo) {
|
|
|
|
[foo left_sub]; // expected-warning{{instance method '-left_sub' not found (return type defaults to 'id')}}
|
|
|
|
foo.right_sub_prop = foo; // expected-error{{property 'right_sub_prop' not found on object of type 'Foo *'}}
|
|
|
|
int i = foo->right_sub_ivar; // expected-error{{'Foo' does not have a member named 'right_sub_ivar'}}
|
|
|
|
id<P1> p1 = foo; // expected-warning{{initializing 'id<P1>' with an expression of incompatible type 'Foo *'}}
|
|
|
|
id<P2> p2 = foo; // expected-warning{{initializing 'id<P2>' with an expression of incompatible type 'Foo *'}}
|
2013-01-17 08:38:46 +08:00
|
|
|
id<P3> p3;
|
|
|
|
[p3 p3_method]; // expected-warning{{instance method '-p3_method' not found (return type defaults to 'id')}}
|
|
|
|
id<P4> p4;
|
|
|
|
[p4 p4_method]; // expected-warning{{instance method '-p4_method' not found (return type defaults to 'id')}}
|
|
|
|
id p3p = p3.p3_prop; // expected-error{{property 'p3_prop' not found on object of type 'id<P3>'}}
|
|
|
|
p3p = foo.p3_prop; // expected-error{{property 'p3_prop' not found on object of type 'Foo *'}}
|
|
|
|
id p4p = p4.p4_prop; // expected-error{{property 'p4_prop' not found on object of type 'id<P4>'}}
|
|
|
|
p4p = foo.p4_prop; // expected-error{{property 'p4_prop' not found on object of type 'Foo *'}}
|
2013-01-17 07:00:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@import category_left.sub;
|
|
|
|
|
|
|
|
void test_hidden_right_errors(Foo *foo) {
|
|
|
|
// These are okay
|
|
|
|
[foo left_sub]; // okay
|
|
|
|
id<P1> p1 = foo;
|
2013-01-17 08:38:46 +08:00
|
|
|
id<P3> p3;
|
|
|
|
[p3 p3_method];
|
|
|
|
id p3p = p3.p3_prop;
|
|
|
|
p3p = foo.p3_prop;
|
|
|
|
// These should fail
|
2013-01-17 07:00:23 +08:00
|
|
|
foo.right_sub_prop = foo; // expected-error{{property 'right_sub_prop' not found on object of type 'Foo *'}}
|
|
|
|
int i = foo->right_sub_ivar; // expected-error{{'Foo' does not have a member named 'right_sub_ivar'}}
|
|
|
|
id<P2> p2 = foo; // expected-warning{{initializing 'id<P2>' with an expression of incompatible type 'Foo *'}}
|
2013-01-17 08:38:46 +08:00
|
|
|
id<P4> p4;
|
|
|
|
[p4 p4_method]; // expected-warning{{instance method '-p4_method' not found (return type defaults to 'id')}}
|
|
|
|
id p4p = p4.p4_prop; // expected-error{{property 'p4_prop' not found on object of type 'id<P4>'}}
|
|
|
|
p4p = foo.p4_prop; // expected-error{{property 'p4_prop' not found on object of type 'Foo *'; did you mean 'p3_prop'?}}
|
|
|
|
// expected-note@7{{'p3_prop' declared here}}
|
2013-01-17 07:00:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@import category_right.sub;
|
|
|
|
|
|
|
|
void test_hidden_okay(Foo *foo) {
|
|
|
|
[foo left_sub];
|
|
|
|
foo.right_sub_prop = foo;
|
|
|
|
int i = foo->right_sub_ivar;
|
|
|
|
id<P1> p1 = foo;
|
|
|
|
id<P2> p2 = foo;
|
2013-01-17 08:38:46 +08:00
|
|
|
id<P3> p3;
|
|
|
|
[p3 p3_method];
|
|
|
|
id<P4> p4;
|
|
|
|
[p4 p4_method];
|
|
|
|
id p3p = p3.p3_prop;
|
|
|
|
p3p = foo.p3_prop;
|
|
|
|
id p4p = p4.p4_prop;
|
|
|
|
p4p = foo.p4_prop;
|
2013-01-17 07:00:23 +08:00
|
|
|
}
|