summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/Modules')
-rw-r--r--clang/test/Modules/Inputs/category_left_sub.h3
-rw-r--r--clang/test/Modules/Inputs/category_right_sub.h9
-rw-r--r--clang/test/Modules/Inputs/category_top.h7
-rw-r--r--clang/test/Modules/Inputs/module.map8
-rw-r--r--clang/test/Modules/objc-categories.m31
5 files changed, 58 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/category_left_sub.h b/clang/test/Modules/Inputs/category_left_sub.h
new file mode 100644
index 00000000000..bee8617dc9e
--- /dev/null
+++ b/clang/test/Modules/Inputs/category_left_sub.h
@@ -0,0 +1,3 @@
+@interface Foo(LeftSub) <P1>
+- (void)left_sub;
+@end
diff --git a/clang/test/Modules/Inputs/category_right_sub.h b/clang/test/Modules/Inputs/category_right_sub.h
new file mode 100644
index 00000000000..696b6cabc04
--- /dev/null
+++ b/clang/test/Modules/Inputs/category_right_sub.h
@@ -0,0 +1,9 @@
+@interface Foo(RightSub) <P2>
+@property id right_sub_prop;
+@end
+
+@interface Foo() {
+@public
+ int right_sub_ivar;
+}
+@end
diff --git a/clang/test/Modules/Inputs/category_top.h b/clang/test/Modules/Inputs/category_top.h
index c9558b6c295..662ae574ec5 100644
--- a/clang/test/Modules/Inputs/category_top.h
+++ b/clang/test/Modules/Inputs/category_top.h
@@ -12,3 +12,10 @@
@interface Foo(Top3)
-(void)top3;
@end
+
+@protocol P1
+@end
+
+@protocol P2
+@end
+
diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map
index 42c6c2b5d94..5ec595c9e1b 100644
--- a/clang/test/Modules/Inputs/module.map
+++ b/clang/test/Modules/Inputs/module.map
@@ -37,10 +37,18 @@ module category_top { header "category_top.h" }
module category_left {
header "category_left.h"
export category_top
+
+ explicit module sub {
+ header "category_left_sub.h"
+ }
}
module category_right {
header "category_right.h"
export category_top
+
+ explicit module sub {
+ header "category_right_sub.h"
+ }
}
module category_bottom {
header "category_bottom.h"
diff --git a/clang/test/Modules/objc-categories.m b/clang/test/Modules/objc-categories.m
index f19dc7efcf0..05a66ca4ee5 100644
--- a/clang/test/Modules/objc-categories.m
+++ b/clang/test/Modules/objc-categories.m
@@ -39,3 +39,34 @@ void test(Foo *foo, LeftFoo *leftFoo) {
void test_other(Foo *foo) {
[foo other];
}
+
+// 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 *'}}
+}
+
+@import category_left.sub;
+
+void test_hidden_right_errors(Foo *foo) {
+ // These are okay
+ [foo left_sub]; // okay
+ id<P1> p1 = foo;
+ // FIXME: these should fail
+ 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 *'}}
+}
+
+@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;
+}
OpenPOWER on IntegriCloud