aboutsummaryrefslogtreecommitdiff
path: root/test/Modules/objc-categories.m
blob: 87aaa5c12cae3f0aadb3f60a2a5c3db3526079fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// RUN: mkdir -p %t
// RUN: %clang_cc1 -emit-module -o %t/diamond_top.pcm %s -D MODULE_TOP
// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash -emit-module -o %t/diamond_left.pcm %s -D MODULE_LEFT
// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash -emit-module -o %t/diamond_right.pcm %s -D MODULE_RIGHT
// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash -emit-module -o %t/diamond_bottom.pcm %s -D MODULE_BOTTOM
// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash %s -verify

/*============================================================================*/
#ifdef MODULE_TOP

@interface Foo
@end

@interface Foo(Top)
-(void)top;
@end

/*============================================================================*/
#elif defined(MODULE_LEFT)

__import_module__ diamond_top;

@interface Foo(Left)
-(void)left;
@end

@interface LeftFoo
-(void)left;
@end

@interface Foo(Duplicate) // expected-note {{previous definition}}
@end

@interface Foo(Duplicate)
@end

/*============================================================================*/
#elif defined(MODULE_RIGHT)

__import_module__ diamond_top;

@interface Foo(Right1)
-(void)right1;
@end

@interface Foo(Right2)
-(void)right2;
@end

@interface Foo(Duplicate) // expected-warning {{duplicate definition of category}}
@end

/*============================================================================*/
#elif defined(MODULE_BOTTOM)

__import_module__ diamond_left;

@interface Foo(Bottom)
-(void)bottom;
@end

__import_module__ diamond_right;

@interface LeftFoo(Bottom)
-(void)bottom;
@end

/*============================================================================*/
#else

__import_module__ diamond_bottom;

@interface Foo(Source)
-(void)source;
@end

void test(Foo *foo, LeftFoo *leftFoo) {
  [foo source];
  [foo bottom];
  [foo left];
  [foo right1];
  [foo right2];
  [foo top];

  [leftFoo left];
  [leftFoo bottom];
}

#endif