Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
Douglas Gregor | 674949f | 2012-01-03 17:31:38 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify |
| 3 | // RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 4 | @class C2; |
| 5 | @class C3; |
| 6 | @class C3; |
Douglas Gregor | 5948ae1 | 2012-01-03 18:04:46 +0000 | [diff] [blame^] | 7 | @import redecl_merge_left; |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 8 | |
Douglas Gregor | dba9361 | 2012-01-01 21:47:52 +0000 | [diff] [blame] | 9 | @protocol P4; |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 10 | @class C3; |
| 11 | @class C3; |
Douglas Gregor | 5948ae1 | 2012-01-03 18:04:46 +0000 | [diff] [blame^] | 12 | @import redecl_merge_right; |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 13 | |
| 14 | @implementation A |
| 15 | - (Super*)init { return self; } |
| 16 | @end |
| 17 | |
| 18 | void f(A *a) { |
| 19 | [a init]; |
| 20 | } |
| 21 | |
| 22 | @class A; |
| 23 | |
Douglas Gregor | adafc2e | 2011-12-19 16:14:14 +0000 | [diff] [blame] | 24 | B *f1() { |
| 25 | return [B create_a_B]; |
| 26 | } |
| 27 | |
Douglas Gregor | ecb1938 | 2011-12-19 15:27:36 +0000 | [diff] [blame] | 28 | @class B; |
| 29 | |
Douglas Gregor | 27c6da2 | 2012-01-01 20:30:41 +0000 | [diff] [blame] | 30 | void testProtoMerge(id<P1> p1, id<P2> p2) { |
| 31 | [p1 protoMethod1]; |
| 32 | [p2 protoMethod2]; |
| 33 | } |
| 34 | |
Douglas Gregor | 2ccd89c | 2011-12-20 18:11:52 +0000 | [diff] [blame] | 35 | // Test redeclarations of entities in explicit submodules, to make |
| 36 | // sure we're maintaining the declaration chains even when normal name |
| 37 | // lookup can't see what we're looking for. |
| 38 | void testExplicit() { |
| 39 | Explicit *e; |
| 40 | int *(*fp)(void) = &explicit_func; |
| 41 | int *ip = explicit_func(); |
| 42 | |
| 43 | // FIXME: Should complain about definition not having been imported. |
| 44 | struct explicit_struct es = { 0 }; |
| 45 | } |
| 46 | |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 47 | // Test resolution of declarations from multiple modules with no |
| 48 | // common original declaration. |
| 49 | void test_C(C *c) { |
| 50 | c = get_a_C(); |
| 51 | accept_a_C(c); |
| 52 | } |
| 53 | |
| 54 | void test_C2(C2 *c2) { |
| 55 | c2 = get_a_C2(); |
| 56 | accept_a_C2(c2); |
| 57 | } |
| 58 | |
| 59 | void test_C3(C3 *c3) { |
| 60 | c3 = get_a_C3(); |
| 61 | accept_a_C3(c3); |
| 62 | } |
| 63 | |
Douglas Gregor | cce54aa | 2011-12-22 19:44:59 +0000 | [diff] [blame] | 64 | C4 *global_C4; |
Douglas Gregor | 5948ae1 | 2012-01-03 18:04:46 +0000 | [diff] [blame^] | 65 | @import redecl_merge_left_left; |
Douglas Gregor | cce54aa | 2011-12-22 19:44:59 +0000 | [diff] [blame] | 66 | |
Douglas Gregor | c3cfd2a | 2011-12-22 21:40:42 +0000 | [diff] [blame] | 67 | void test_C4a(C4 *c4) { |
Douglas Gregor | cce54aa | 2011-12-22 19:44:59 +0000 | [diff] [blame] | 68 | global_C4 = c4 = get_a_C4(); |
| 69 | accept_a_C4(c4); |
| 70 | } |
| 71 | |
Douglas Gregor | 5948ae1 | 2012-01-03 18:04:46 +0000 | [diff] [blame^] | 72 | @import redecl_merge_bottom; |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 73 | |
Douglas Gregor | c3cfd2a | 2011-12-22 21:40:42 +0000 | [diff] [blame] | 74 | void test_C4b() { |
| 75 | if (&refers_to_C4) { |
| 76 | } |
| 77 | } |
| 78 | |
Douglas Gregor | ecb1938 | 2011-12-19 15:27:36 +0000 | [diff] [blame] | 79 | @implementation B |
Douglas Gregor | adafc2e | 2011-12-19 16:14:14 +0000 | [diff] [blame] | 80 | + (B*)create_a_B { return 0; } |
Douglas Gregor | ecb1938 | 2011-12-19 15:27:36 +0000 | [diff] [blame] | 81 | @end |
| 82 | |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 83 | void g(A *a) { |
| 84 | [a init]; |
| 85 | } |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 86 | |
Douglas Gregor | dba9361 | 2012-01-01 21:47:52 +0000 | [diff] [blame] | 87 | @protocol P3 |
| 88 | - (void)p3_method; |
| 89 | @end |
| 90 | |
| 91 | id<P4> p4; |
| 92 | id<P3> p3; |
| 93 | |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 94 | #ifdef __cplusplus |
| 95 | void testVector() { |
Douglas Gregor | fc529f7 | 2011-12-19 19:00:47 +0000 | [diff] [blame] | 96 | Vector<int> vec_int; |
| 97 | vec_int.push_back(0); |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 98 | } |
| 99 | #endif |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 100 | |