blob: d7927396cab9a225db18a1b11105ee8244ed73c3 [file] [log] [blame]
Douglas Gregora1be2782011-12-17 23:38:30 +00001// RUN: rm -rf %t
2// RUN: %clang_cc1 -fmodule-cache-path %t -I %S/Inputs %s -verify
Douglas Gregor68d7bb92011-12-19 14:42:41 +00003// RUN: %clang_cc1 -x objective-c++ -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 Gregora1be2782011-12-17 23:38:30 +00007__import_module__ redecl_merge_left;
Douglas Gregor0f753232011-12-22 01:48:48 +00008
9@class C3;
10@class C3;
Douglas Gregora1be2782011-12-17 23:38:30 +000011__import_module__ redecl_merge_right;
12
13@implementation A
14- (Super*)init { return self; }
15@end
16
17void f(A *a) {
18 [a init];
19}
20
21@class A;
22
Douglas Gregoradafc2e2011-12-19 16:14:14 +000023B *f1() {
24 return [B create_a_B];
25}
26
Douglas Gregorecb19382011-12-19 15:27:36 +000027@class B;
28
Douglas Gregor27c6da22012-01-01 20:30:41 +000029void testProtoMerge(id<P1> p1, id<P2> p2) {
30 [p1 protoMethod1];
31 [p2 protoMethod2];
32}
33
Douglas Gregor2ccd89c2011-12-20 18:11:52 +000034// Test redeclarations of entities in explicit submodules, to make
35// sure we're maintaining the declaration chains even when normal name
36// lookup can't see what we're looking for.
37void testExplicit() {
38 Explicit *e;
39 int *(*fp)(void) = &explicit_func;
40 int *ip = explicit_func();
41
42 // FIXME: Should complain about definition not having been imported.
43 struct explicit_struct es = { 0 };
44}
45
Douglas Gregor0f753232011-12-22 01:48:48 +000046// Test resolution of declarations from multiple modules with no
47// common original declaration.
48void test_C(C *c) {
49 c = get_a_C();
50 accept_a_C(c);
51}
52
53void test_C2(C2 *c2) {
54 c2 = get_a_C2();
55 accept_a_C2(c2);
56}
57
58void test_C3(C3 *c3) {
59 c3 = get_a_C3();
60 accept_a_C3(c3);
61}
62
Douglas Gregorcce54aa2011-12-22 19:44:59 +000063C4 *global_C4;
64__import_module__ redecl_merge_left_left;
65
Douglas Gregorc3cfd2a2011-12-22 21:40:42 +000066void test_C4a(C4 *c4) {
Douglas Gregorcce54aa2011-12-22 19:44:59 +000067 global_C4 = c4 = get_a_C4();
68 accept_a_C4(c4);
69}
70
Douglas Gregora1be2782011-12-17 23:38:30 +000071__import_module__ redecl_merge_bottom;
72
Douglas Gregorc3cfd2a2011-12-22 21:40:42 +000073void test_C4b() {
74 if (&refers_to_C4) {
75 }
76}
77
Douglas Gregorecb19382011-12-19 15:27:36 +000078@implementation B
Douglas Gregoradafc2e2011-12-19 16:14:14 +000079+ (B*)create_a_B { return 0; }
Douglas Gregorecb19382011-12-19 15:27:36 +000080@end
81
Douglas Gregora1be2782011-12-17 23:38:30 +000082void g(A *a) {
83 [a init];
84}
Douglas Gregorf63b0a52011-12-19 18:19:24 +000085
86#ifdef __cplusplus
87void testVector() {
Douglas Gregorfc529f72011-12-19 19:00:47 +000088 Vector<int> vec_int;
89 vec_int.push_back(0);
Douglas Gregorf63b0a52011-12-19 18:19:24 +000090}
91#endif
Douglas Gregor0f753232011-12-22 01:48:48 +000092