blob: c0e83e8a86495bfbd14a962b897e636ca5d4a4ca [file] [log] [blame]
Douglas Gregora1be2782011-12-17 23:38:30 +00001// RUN: rm -rf %t
Douglas Gregor674949f2012-01-03 17:31:38 +00002// 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 Gregor0f753232011-12-22 01:48:48 +00004@class C2;
5@class C3;
6@class C3;
Douglas Gregor5948ae12012-01-03 18:04:46 +00007@import redecl_merge_left;
Douglas Gregor0f753232011-12-22 01:48:48 +00008
Douglas Gregordba93612012-01-01 21:47:52 +00009@protocol P4;
Douglas Gregor0f753232011-12-22 01:48:48 +000010@class C3;
11@class C3;
Douglas Gregor5948ae12012-01-03 18:04:46 +000012@import redecl_merge_right;
Douglas Gregora1be2782011-12-17 23:38:30 +000013
14@implementation A
15- (Super*)init { return self; }
16@end
17
18void f(A *a) {
19 [a init];
20}
21
22@class A;
23
Douglas Gregoradafc2e2011-12-19 16:14:14 +000024B *f1() {
25 return [B create_a_B];
26}
27
Douglas Gregorecb19382011-12-19 15:27:36 +000028@class B;
29
Douglas Gregor27c6da22012-01-01 20:30:41 +000030void testProtoMerge(id<P1> p1, id<P2> p2) {
31 [p1 protoMethod1];
32 [p2 protoMethod2];
33}
34
Douglas Gregor1ca4a5c2012-01-03 22:46:00 +000035struct S1 {
36 int s1_field;
37};
38
39struct S3 {
40 int s3_field;
41};
42
43void testTagMerge() {
44 consume_S1(produce_S1());
45 struct S2 s2;
46 s2.field = 0;
47 consume_S2(produce_S2());
48 struct S1 s1;
49 s1.s1_field = 0;
50 consume_S3(produce_S3());
51 struct S4 s4;
52 s4.field = 0;
53 consume_S4(produce_S4());
54 struct S3 s3;
55 s3.s3_field = 0;
56}
57
Douglas Gregor2ccd89c2011-12-20 18:11:52 +000058// Test redeclarations of entities in explicit submodules, to make
59// sure we're maintaining the declaration chains even when normal name
60// lookup can't see what we're looking for.
61void testExplicit() {
62 Explicit *e;
63 int *(*fp)(void) = &explicit_func;
64 int *ip = explicit_func();
65
66 // FIXME: Should complain about definition not having been imported.
67 struct explicit_struct es = { 0 };
68}
69
Douglas Gregor0f753232011-12-22 01:48:48 +000070// Test resolution of declarations from multiple modules with no
71// common original declaration.
72void test_C(C *c) {
73 c = get_a_C();
74 accept_a_C(c);
75}
76
77void test_C2(C2 *c2) {
78 c2 = get_a_C2();
79 accept_a_C2(c2);
80}
81
82void test_C3(C3 *c3) {
83 c3 = get_a_C3();
84 accept_a_C3(c3);
85}
86
Douglas Gregorcce54aa2011-12-22 19:44:59 +000087C4 *global_C4;
Douglas Gregor5948ae12012-01-03 18:04:46 +000088@import redecl_merge_left_left;
Douglas Gregorcce54aa2011-12-22 19:44:59 +000089
Douglas Gregorc3cfd2a2011-12-22 21:40:42 +000090void test_C4a(C4 *c4) {
Douglas Gregorcce54aa2011-12-22 19:44:59 +000091 global_C4 = c4 = get_a_C4();
92 accept_a_C4(c4);
93}
94
Douglas Gregor5948ae12012-01-03 18:04:46 +000095@import redecl_merge_bottom;
Douglas Gregora1be2782011-12-17 23:38:30 +000096
Douglas Gregorc3cfd2a2011-12-22 21:40:42 +000097void test_C4b() {
98 if (&refers_to_C4) {
99 }
100}
101
Douglas Gregorecb19382011-12-19 15:27:36 +0000102@implementation B
Douglas Gregoradafc2e2011-12-19 16:14:14 +0000103+ (B*)create_a_B { return 0; }
Douglas Gregorecb19382011-12-19 15:27:36 +0000104@end
105
Douglas Gregora1be2782011-12-17 23:38:30 +0000106void g(A *a) {
107 [a init];
108}
Douglas Gregorf63b0a52011-12-19 18:19:24 +0000109
Douglas Gregordba93612012-01-01 21:47:52 +0000110@protocol P3
111- (void)p3_method;
112@end
113
114id<P4> p4;
115id<P3> p3;
116
Douglas Gregorf63b0a52011-12-19 18:19:24 +0000117#ifdef __cplusplus
118void testVector() {
Douglas Gregorfc529f72011-12-19 19:00:47 +0000119 Vector<int> vec_int;
120 vec_int.push_back(0);
Douglas Gregorf63b0a52011-12-19 18:19:24 +0000121}
122#endif
Douglas Gregor0f753232011-12-22 01:48:48 +0000123