1d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor// RUN: %clang_cc1 -fsyntax-only -verify %s
2d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
3d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor// This test checks for the various conversions and casting operations
4d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor// with address-space-qualified pointers.
5d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
6d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregorstruct A { virtual ~A() {} };
7d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregorstruct B : A { };
8d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
9d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef void *void_ptr;
10d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef void __attribute__((address_space(1))) *void_ptr_1;
11d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef void __attribute__((address_space(2))) *void_ptr_2;
12d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
13d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef int *int_ptr;
14d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef int __attribute__((address_space(1))) *int_ptr_1;
15d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef int __attribute__((address_space(2))) *int_ptr_2;
16d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
17d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef A *A_ptr;
18d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef A __attribute__((address_space(1))) *A_ptr_1;
19d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef A __attribute__((address_space(2))) *A_ptr_2;
20d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
21d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef B *B_ptr;
22d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef B __attribute__((address_space(1))) *B_ptr_1;
23d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregortypedef B __attribute__((address_space(2))) *B_ptr_2;
24d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
25d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregorvoid test_const_cast(int_ptr ip, int_ptr_1 ip1, int_ptr_2 ip2,
26d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                     A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
27d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                     const int *cip,
28d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                     const int __attribute__((address_space(1))) *cip1) {
29d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Cannot use const_cast to cast between address spaces, add an
30d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // address space, or remove an address space.
31d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<int_ptr>(ip1); // expected-error{{is not allowed}}
32d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<int_ptr>(ip2); // expected-error{{is not allowed}}
33d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<int_ptr_1>(ip); // expected-error{{is not allowed}}
34d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<int_ptr_1>(ip2); // expected-error{{is not allowed}}
35d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<int_ptr_2>(ip); // expected-error{{is not allowed}}
36d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<int_ptr_2>(ip1); // expected-error{{is not allowed}}
37d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
38d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<A_ptr>(ap1); // expected-error{{is not allowed}}
39d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<A_ptr>(ap2); // expected-error{{is not allowed}}
40d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<A_ptr_1>(ap); // expected-error{{is not allowed}}
41d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<A_ptr_1>(ap2); // expected-error{{is not allowed}}
42d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<A_ptr_2>(ap); // expected-error{{is not allowed}}
43d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<A_ptr_2>(ap1); // expected-error{{is not allowed}}
44d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
45d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // It's acceptable to cast away constness.
46d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<int_ptr>(cip);
47d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)const_cast<int_ptr_1>(cip1);
48d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor}
49d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
50d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregorvoid test_static_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
51d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                      A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
52d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                      B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) {
53d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Well-formed upcast
54d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr>(bp);
55d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_1>(bp1);
56d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_2>(bp2);
57d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
58d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Well-formed downcast
59d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<B_ptr>(ap);
60d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<B_ptr_1>(ap1);
61d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<B_ptr_2>(ap2);
62d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
63d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Well-formed cast to/from void
64d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<void_ptr>(ap);
65d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<void_ptr_1>(ap1);
66d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<void_ptr_2>(ap2);
67d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr>(vp);
68d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_1>(vp1);
69d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_2>(vp2);
70d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
71d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Ill-formed upcasts
72d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr>(bp1); // expected-error{{is not allowed}}
73d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr>(bp2); // expected-error{{is not allowed}}
74d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_1>(bp); // expected-error{{is not allowed}}
75d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_1>(bp2); // expected-error{{is not allowed}}
76d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_2>(bp); // expected-error{{is not allowed}}
77d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_2>(bp1); // expected-error{{is not allowed}}
78d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
79d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Ill-formed downcasts
80d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<B_ptr>(ap1); // expected-error{{casts away qualifiers}}
81d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<B_ptr>(ap2); // expected-error{{casts away qualifiers}}
82d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<B_ptr_1>(ap); // expected-error{{casts away qualifiers}}
83d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<B_ptr_1>(ap2); // expected-error{{casts away qualifiers}}
84d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<B_ptr_2>(ap); // expected-error{{casts away qualifiers}}
85d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<B_ptr_2>(ap1); // expected-error{{casts away qualifiers}}
86d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
87d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Ill-formed cast to/from void
88d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<void_ptr>(ap1); // expected-error{{is not allowed}}
89d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<void_ptr>(ap2); // expected-error{{is not allowed}}
90d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<void_ptr_1>(ap); // expected-error{{is not allowed}}
91d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<void_ptr_1>(ap2); // expected-error{{is not allowed}}
92d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<void_ptr_2>(ap); // expected-error{{is not allowed}}
93d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<void_ptr_2>(ap1); // expected-error{{is not allowed}}
94d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr>(vp1); // expected-error{{casts away qualifiers}}
95d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr>(vp2); // expected-error{{casts away qualifiers}}
96d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_1>(vp); // expected-error{{casts away qualifiers}}
97d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_1>(vp2); // expected-error{{casts away qualifiers}}
98d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_2>(vp); // expected-error{{casts away qualifiers}}
99d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)static_cast<A_ptr_2>(vp1); // expected-error{{casts away qualifiers}}
100d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor}
101d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
102d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregorvoid test_dynamic_cast(A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
103d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                       B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) {
104d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Well-formed upcast
105d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<A_ptr>(bp);
106d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<A_ptr_1>(bp1);
107d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<A_ptr_2>(bp2);
108d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
109d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Well-formed downcast
110d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<B_ptr>(ap);
111d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<B_ptr_1>(ap1);
112d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<B_ptr_2>(ap2);
113d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
114d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Ill-formed upcasts
115d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<A_ptr>(bp1); // expected-error{{casts away qualifiers}}
116d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<A_ptr>(bp2); // expected-error{{casts away qualifiers}}
117d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<A_ptr_1>(bp); // expected-error{{casts away qualifiers}}
118d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<A_ptr_1>(bp2); // expected-error{{casts away qualifiers}}
119d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<A_ptr_2>(bp); // expected-error{{casts away qualifiers}}
120d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<A_ptr_2>(bp1); // expected-error{{casts away qualifiers}}
121d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
122d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Ill-formed downcasts
123d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<B_ptr>(ap1); // expected-error{{casts away qualifiers}}
124d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<B_ptr>(ap2); // expected-error{{casts away qualifiers}}
125d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<B_ptr_1>(ap); // expected-error{{casts away qualifiers}}
126d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<B_ptr_1>(ap2); // expected-error{{casts away qualifiers}}
127d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<B_ptr_2>(ap); // expected-error{{casts away qualifiers}}
128d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)dynamic_cast<B_ptr_2>(ap1); // expected-error{{casts away qualifiers}}
129d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor}
130d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
131d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregorvoid test_reinterpret_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
132d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                           A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
133d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                           B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2,
134d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                           const void __attribute__((address_space(1))) *cvp1) {
135d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // reinterpret_cast can be used to cast to a different address space.
136d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr>(ap1);
137d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr>(ap2);
138d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr>(bp);
139d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr>(bp1);
140d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr>(bp2);
141d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr>(vp);
142d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr>(vp1);
143d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr>(vp2);
144d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr_1>(ap);
145d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr_1>(ap2);
146d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr_1>(bp);
147d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr_1>(bp1);
148d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr_1>(bp2);
149d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr_1>(vp);
150d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr_1>(vp1);
151d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr_1>(vp2);
152d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
153d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // ... but don't try to cast away constness!
154d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)reinterpret_cast<A_ptr_2>(cvp1); // expected-error{{casts away qualifiers}}
155d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor}
156d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
157d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregorvoid test_cstyle_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
158d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                      A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
159d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                      B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2,
160d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                      const void __attribute__((address_space(1))) *cvp1) {
161d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // C-style casts are the wild west of casts.
162d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr)(ap1);
163d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr)(ap2);
164d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr)(bp);
165d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr)(bp1);
166d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr)(bp2);
167d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr)(vp);
168d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr)(vp1);
169d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr)(vp2);
170d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr_1)(ap);
171d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr_1)(ap2);
172d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr_1)(bp);
173d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr_1)(bp1);
174d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr_1)(bp2);
175d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr_1)(vp);
176d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr_1)(vp1);
177d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr_1)(vp2);
178d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  (void)(A_ptr_2)(cvp1);
179d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor}
180d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
181d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregorvoid test_implicit_conversion(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
182d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                              A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
183d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor                              B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) {
184d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Well-formed conversions
185d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  void_ptr vpA = ap;
186d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  void_ptr_1 vp_1A = ap1;
187d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  void_ptr_2 vp_2A = ap2;
188d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  A_ptr ap_A = bp;
189d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  A_ptr_1 ap_A1 = bp1;
190d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  A_ptr_2 ap_A2 = bp2;
191d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor
192d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  // Ill-formed conversions
193d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  void_ptr vpB = ap1; // expected-error{{cannot initialize a variable of type}}
194d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  void_ptr_1 vp_1B = ap2; // expected-error{{cannot initialize a variable of type}}
195d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  A_ptr ap_B = bp1; // expected-error{{cannot initialize a variable of type}}
196d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor  A_ptr_1 ap_B1 = bp2; // expected-error{{cannot initialize a variable of type}}
197d4c5f84bbed2ecb5ddd0f0e8316c553b2084772aDouglas Gregor}
198