Douglas Gregor | 4ba7c2a | 2011-11-16 15:22:03 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
Douglas Gregor | 0bf886d | 2012-01-03 18:24:14 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_top -emit-module %S/Inputs/module.map |
| 3 | // RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_left -emit-module %S/Inputs/module.map |
| 4 | // RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.map |
| 5 | // RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.map |
Douglas Gregor | 404cdde | 2012-01-27 01:47:08 +0000 | [diff] [blame] | 6 | // RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_other -emit-module %S/Inputs/module.map |
Douglas Gregor | 0bf886d | 2012-01-03 18:24:14 +0000 | [diff] [blame] | 7 | // RUN: %clang_cc1 -fmodules -fmodule-cache-path %t %s -verify |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 8 | |
Douglas Gregor | c50d492 | 2012-12-11 22:11:52 +0000 | [diff] [blame] | 9 | @import category_bottom; |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 10 | |
Douglas Gregor | 6ac0b71 | 2011-09-01 19:02:18 +0000 | [diff] [blame] | 11 | |
Douglas Gregor | 404cdde | 2012-01-27 01:47:08 +0000 | [diff] [blame] | 12 | |
| 13 | |
Douglas Gregor | 4ba7c2a | 2011-11-16 15:22:03 +0000 | [diff] [blame] | 14 | // in category_left.h: expected-note {{previous definition}} |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 15 | // in category_right.h: expected-warning@11 {{duplicate definition of category}} |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 16 | |
| 17 | @interface Foo(Source) |
Douglas Gregor | 4ba7c2a | 2011-11-16 15:22:03 +0000 | [diff] [blame] | 18 | -(void)source; |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 19 | @end |
| 20 | |
| 21 | void test(Foo *foo, LeftFoo *leftFoo) { |
| 22 | [foo source]; |
| 23 | [foo bottom]; |
| 24 | [foo left]; |
| 25 | [foo right1]; |
| 26 | [foo right2]; |
| 27 | [foo top]; |
Douglas Gregor | 404cdde | 2012-01-27 01:47:08 +0000 | [diff] [blame] | 28 | [foo top2]; |
| 29 | [foo top3]; |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 30 | |
| 31 | [leftFoo left]; |
| 32 | [leftFoo bottom]; |
| 33 | } |
Douglas Gregor | 404cdde | 2012-01-27 01:47:08 +0000 | [diff] [blame] | 34 | |
| 35 | // Load another module that also adds categories to Foo, verify that |
| 36 | // we see those categories. |
Douglas Gregor | c50d492 | 2012-12-11 22:11:52 +0000 | [diff] [blame] | 37 | @import category_other; |
Douglas Gregor | 404cdde | 2012-01-27 01:47:08 +0000 | [diff] [blame] | 38 | |
| 39 | void test_other(Foo *foo) { |
| 40 | [foo other]; |
| 41 | } |
Douglas Gregor | 048fbfa | 2013-01-16 23:00:23 +0000 | [diff] [blame^] | 42 | |
| 43 | // Make sure we don't see categories that should be hidden |
| 44 | void test_hidden_all_errors(Foo *foo) { |
| 45 | [foo left_sub]; // expected-warning{{instance method '-left_sub' not found (return type defaults to 'id')}} |
| 46 | foo.right_sub_prop = foo; // expected-error{{property 'right_sub_prop' not found on object of type 'Foo *'}} |
| 47 | int i = foo->right_sub_ivar; // expected-error{{'Foo' does not have a member named 'right_sub_ivar'}} |
| 48 | id<P1> p1 = foo; // expected-warning{{initializing 'id<P1>' with an expression of incompatible type 'Foo *'}} |
| 49 | id<P2> p2 = foo; // expected-warning{{initializing 'id<P2>' with an expression of incompatible type 'Foo *'}} |
| 50 | } |
| 51 | |
| 52 | @import category_left.sub; |
| 53 | |
| 54 | void test_hidden_right_errors(Foo *foo) { |
| 55 | // These are okay |
| 56 | [foo left_sub]; // okay |
| 57 | id<P1> p1 = foo; |
| 58 | // FIXME: these should fail |
| 59 | foo.right_sub_prop = foo; // expected-error{{property 'right_sub_prop' not found on object of type 'Foo *'}} |
| 60 | int i = foo->right_sub_ivar; // expected-error{{'Foo' does not have a member named 'right_sub_ivar'}} |
| 61 | id<P2> p2 = foo; // expected-warning{{initializing 'id<P2>' with an expression of incompatible type 'Foo *'}} |
| 62 | } |
| 63 | |
| 64 | @import category_right.sub; |
| 65 | |
| 66 | void test_hidden_okay(Foo *foo) { |
| 67 | [foo left_sub]; |
| 68 | foo.right_sub_prop = foo; |
| 69 | int i = foo->right_sub_ivar; |
| 70 | id<P1> p1 = foo; |
| 71 | id<P2> p2 = foo; |
| 72 | } |