2011-11-16 23:22:03 +08:00
|
|
|
// RUN: rm -rf %t
|
2015-06-16 08:08:24 +08:00
|
|
|
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=category_top -emit-module %S/Inputs/module.map
|
|
|
|
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=category_left -emit-module %S/Inputs/module.map
|
|
|
|
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.map
|
|
|
|
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.map
|
|
|
|
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=category_other -emit-module %S/Inputs/module.map
|
|
|
|
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %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
|
|
|
|
2013-04-17 16:06:46 +08:00
|
|
|
// expected-note@Inputs/category_left.h:14 {{previous definition}}
|
2016-02-05 09:10:05 +08:00
|
|
|
// expected-warning@Inputs/category_right.h:12 {{duplicate definition of category}}
|
2013-05-15 23:27:35 +08:00
|
|
|
// expected-note@Inputs/category_top.h:1 {{receiver is instance of class declared here}}
|
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'?}}
|
2013-04-17 16:06:46 +08:00
|
|
|
// expected-note@Inputs/category_left_sub.h: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
|
|
|
}
|