brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · a2f3313 Raw
100 lines · plain
1// RUN: rm -rf %t2// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=category_top -emit-module %S/Inputs/module.modulemap3// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=category_left -emit-module %S/Inputs/module.modulemap4// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.modulemap5// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.modulemap6// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=category_other -emit-module %S/Inputs/module.modulemap7// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify8 9@import category_bottom;10 11// expected-note@Inputs/category_top.h:1 {{receiver is instance of class declared here}}12 13@interface Foo(Source)14-(void)source; 15@end16 17void test(Foo *foo, LeftFoo *leftFoo) {18  [foo source];19  [foo bottom];20  [foo left];21  [foo right1];22  [foo right2];23  [foo top];24  [foo top2];25  [foo top3];26 27  [leftFoo left];28  [leftFoo bottom];29}30 31// Load another module that also adds categories to Foo, verify that32// we see those categories.33@import category_other;34 35void test_other(Foo *foo) {36  [foo other];37}38 39// Make sure we don't see categories that should be hidden40void test_hidden_all_errors(Foo *foo) {41  [foo left_sub]; // expected-warning{{instance method '-left_sub' not found (return type defaults to 'id')}}42  foo.right_sub_prop = foo; // expected-error{{property 'right_sub_prop' not found on object of type 'Foo *'}}43  int i = foo->right_sub_ivar; // expected-error{{'Foo' does not have a member named 'right_sub_ivar'}}44  id<P1> p1 = foo; // expected-warning{{initializing 'id<P1>' with an expression of incompatible type 'Foo *'}}45  id<P2> p2 = foo; // expected-warning{{initializing 'id<P2>' with an expression of incompatible type 'Foo *'}}46  id<P3> p3;47  [p3 p3_method]; // expected-warning{{instance method '-p3_method' not found (return type defaults to 'id')}}48  id<P4> p4;49  [p4 p4_method]; // expected-warning{{instance method '-p4_method' not found (return type defaults to 'id')}}50  id p3p = p3.p3_prop; // expected-error{{property 'p3_prop' not found on object of type 'id<P3>'}}51  p3p = foo.p3_prop; // expected-error{{property 'p3_prop' not found on object of type 'Foo *'}}52  id p4p = p4.p4_prop; // expected-error{{property 'p4_prop' not found on object of type 'id<P4>'}}53  p4p = foo.p4_prop; // expected-error{{property 'p4_prop' not found on object of type 'Foo *'}}54 55  if (foo.hiddenPropertyFromExtension) { // expected-error {{property 'hiddenPropertyFromExtension' not found on object of type 'Foo *'}}56  }57}58 59@import category_left.sub;60 61void test_hidden_right_errors(Foo *foo) {62  // These are okay63  [foo left_sub]; // okay64  id<P1> p1 = foo;65  id<P3> p3;66  [p3 p3_method];67  id p3p = p3.p3_prop;68  p3p = foo.p3_prop;69  // These should fail70  foo.right_sub_prop = foo; // expected-error{{property 'right_sub_prop' not found on object of type 'Foo *'}}71  int i = foo->right_sub_ivar; // expected-error{{'Foo' does not have a member named 'right_sub_ivar'}}72  id<P2> p2 = foo; // expected-warning{{initializing 'id<P2>' with an expression of incompatible type 'Foo *'}}73  id<P4> p4;74  [p4 p4_method]; // expected-warning{{instance method '-p4_method' not found (return type defaults to 'id')}}75  id p4p = p4.p4_prop; // expected-error{{property 'p4_prop' not found on object of type 'id<P4>'}}76  p4p = foo.p4_prop; // expected-error{{property 'p4_prop' not found on object of type 'Foo *'; did you mean 'p3_prop'?}}77  // expected-note@Inputs/category_left_sub.h:7{{'p3_prop' declared here}}78  int hiddenFromExtension = foo.hiddenPropertyFromExtension; // expected-error {{property 'hiddenPropertyFromExtension' not found on object of type 'Foo *'}}79}80 81@import category_right.sub;82 83void test_hidden_okay(Foo *foo) {84  [foo left_sub];85  foo.right_sub_prop = foo;86  int i = foo->right_sub_ivar;87  id<P1> p1 = foo;88  id<P2> p2 = foo;89  id<P3> p3;90  [p3 p3_method];91  id<P4> p4;92  [p4 p4_method];93  id p3p = p3.p3_prop;94  p3p = foo.p3_prop;95  id p4p = p4.p4_prop;96  p4p = foo.p4_prop;97  if (foo.hiddenPropertyFromExtension) {98  }99}100