redecl-merge.m revision c3cfd2ab3338d47861ece597212f21b972ebe727
1// RUN: rm -rf %t
2// RUN: %clang_cc1 -fmodule-cache-path %t -I %S/Inputs %s -verify
3// RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -I %S/Inputs %s -verify
4@class C2;
5@class C3;
6@class C3;
7__import_module__ redecl_merge_left;
8
9@class C3;
10@class C3;
11__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
23B *f1() {
24  return [B create_a_B];
25}
26
27@class B;
28
29// Test redeclarations of entities in explicit submodules, to make
30// sure we're maintaining the declaration chains even when normal name
31// lookup can't see what we're looking for.
32void testExplicit() {
33  Explicit *e;
34  int *(*fp)(void) = &explicit_func;
35  int *ip = explicit_func();
36
37  // FIXME: Should complain about definition not having been imported.
38  struct explicit_struct es = { 0 };
39}
40
41// Test resolution of declarations from multiple modules with no
42// common original declaration.
43void test_C(C *c) {
44  c = get_a_C();
45  accept_a_C(c);
46}
47
48void test_C2(C2 *c2) {
49  c2 = get_a_C2();
50  accept_a_C2(c2);
51}
52
53void test_C3(C3 *c3) {
54  c3 = get_a_C3();
55  accept_a_C3(c3);
56}
57
58C4 *global_C4;
59__import_module__ redecl_merge_left_left;
60
61void test_C4a(C4 *c4) {
62  global_C4 = c4 = get_a_C4();
63  accept_a_C4(c4);
64}
65
66__import_module__ redecl_merge_bottom;
67
68void test_C4b() {
69  if (&refers_to_C4) {
70  }
71}
72
73@implementation B
74+ (B*)create_a_B { return 0; }
75@end
76
77void g(A *a) {
78  [a init];
79}
80
81#ifdef __cplusplus
82void testVector() {
83  Vector<int> vec_int;
84  vec_int.push_back(0);
85}
86#endif
87
88