1 // RUN
: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std
=CL2.0
2 // RUN
: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std
=CL2.0
3 // RUN
: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std
=CL2.0
5 /* OpenCLC v2.0 adds a set of restrictions for conversions between pointers to
6 * different address spaces
, mainly described in Sections
6.5.5 and
6.5.6.
8 * It adds notion of overlapping address spaces. The main differention is that
9 * an unnamed address space is added
, called
'__generic
'. Pointers to the
10 * generic address space can be interchangabley used with pointers to any
11 * other address space except for __constant address space
(Section 6.5.5).
13 * Based on this there are
3 sets of tests
: __generic
, named
(__global in this
14 * case
), and __constant
, that should cover all program paths for CL address
15 * space conversions used in initialisations
, assignments
, casts
, comparisons
16 * and arithmetic operations.
31 void f_glob
(global int
*arg_glob
) {}
33 // expected-note
@-
2{{passing argument to parameter
'arg_glob
' here
}}
36 void f_loc
(local int
*arg_loc
) {
37 } // expected-note
@-
1{{passing argument to parameter
'arg_loc
' here
}}
39 void f_const
(constant int
*arg_const
) {}
41 // expected-note
@-
2{{passing argument to parameter
'arg_const
' here
}}
44 void f_priv
(private int
*arg_priv
) {
45 } // expected-note
@-
1{{passing argument to parameter
'arg_priv
' here
}}
47 void f_gen
(generic int
*arg_gen
) {}
49 // expected-note
@-
2{{passing argument to parameter
'arg_gen
' here
}}
52 void test_conversion
(global int
*arg_glob
, local int
*arg_loc
,
53 constant int
*arg_const
, private int
*arg_priv
,
54 generic int
*arg_gen
) {
56 AS int
*var_init1
= arg_glob
;
58 // expected-error
@-
2{{initializing
'__constant int
*' with an expression of type
'__global int
*' changes address space of pointer
}}
61 AS int
*var_init2
= arg_loc
;
63 // expected-error-re
@-
2{{initializing
'__
{{global|constant
}} int
*' with an expression of type
'__local int
*' changes address space of pointer
}}
66 AS int
*var_init3
= arg_const
;
68 // expected-error-re
@-
2{{initializing
'__
{{global|generic
}} int
*' with an expression of type
'__constant int
*' changes address space of pointer
}}
71 AS int
*var_init4
= arg_priv
;
73 // expected-error-re
@-
2{{initializing
'__
{{global|constant
}} int
*' with an expression of type
'int
*' changes address space of pointer
}}
76 AS int
*var_init5
= arg_gen
;
78 // expected-error-re
@-
2{{initializing
'__
{{global|constant
}} int
*' with an expression of type
'__generic int
*' changes address space of pointer
}}
81 AS int
*var_cast1
= (AS int
*)arg_glob
;
83 // expected-error
@-
2{{casting
'__global int
*' to type
'__constant int
*' changes address space of pointer
}}
86 AS int
*var_cast2
= (AS int
*)arg_loc
;
88 // expected-error-re
@-
2{{casting
'__local int
*' to type
'__
{{global|constant
}} int
*' changes address space of pointer
}}
91 AS int
*var_cast3
= (AS int
*)arg_const
;
93 // expected-error-re
@-
2{{casting
'__constant int
*' to type
'__
{{global|generic
}} int
*' changes address space of pointer
}}
96 AS int
*var_cast4
= (AS int
*)arg_priv
;
98 // expected-error-re
@-
2{{casting
'int
*' to type
'__
{{global|constant
}} int
*' changes address space of pointer
}}
101 AS int
*var_cast5
= (AS int
*)arg_gen
;
103 // expected-error
@-
2{{casting
'__generic int
*' to type
'__constant int
*' changes address space of pointer
}}
109 // expected-error
@-
2{{assigning
'__global int
*' to
'__constant int
*' changes address space of pointer
}}
114 // expected-error-re
@-
2{{assigning
'__local int
*' to
'__
{{global|constant
}} int
*' changes address space of pointer
}}
117 var_impl
= arg_const
;
119 // expected-error-re
@-
2{{assigning
'__constant int
*' to
'__
{{global|generic
}} int
*' changes address space of pointer
}}
124 // expected-error-re
@-
2{{assigning
'int
*' to
'__
{{global|constant
}} int
*' changes address space of pointer
}}
129 // expected-error-re
@-
2{{assigning
'__generic int
*' to
'__
{{global|constant
}} int
*' changes address space of pointer
}}
132 var_cast1
= (AS int
*)arg_glob
;
134 // expected-error
@-
2{{casting
'__global int
*' to type
'__constant int
*' changes address space of pointer
}}
137 var_cast2
= (AS int
*)arg_loc
;
139 // expected-error-re
@-
2{{casting
'__local int
*' to type
'__
{{global|constant
}} int
*' changes address space of pointer
}}
142 var_cast3
= (AS int
*)arg_const
;
144 // expected-error-re
@-
2{{casting
'__constant int
*' to type
'__
{{global|generic
}} int
*' changes address space of pointer
}}
147 var_cast4
= (AS int
*)arg_priv
;
149 // expected-error-re
@-
2{{casting
'int
*' to type
'__
{{global|constant
}} int
*' changes address space of pointer
}}
152 var_cast5
= (AS int
*)arg_gen
;
154 // expected-error
@-
2{{casting
'__generic int
*' to type
'__constant int
*' changes address space of pointer
}}
158 int b
= var_cmp
!= arg_glob
;
160 // expected-error
@-
2{{comparison between
('__constant int
*' and
'__global int
*') which are pointers to non-overlapping address spaces
}}
163 b
= var_cmp
!= arg_loc
;
165 // expected-error-re
@-
2{{comparison between
('__
{{global|constant
}} int
*' and
'__local int
*') which are pointers to non-overlapping address spaces
}}
168 b
= var_cmp
== arg_const
;
170 // expected-error-re
@-
2{{comparison between
('__
{{global|generic
}} int
*' and
'__constant int
*') which are pointers to non-overlapping address spaces
}}
173 b
= var_cmp
<= arg_priv
;
175 // expected-error-re
@-
2{{comparison between
('__
{{global|constant
}} int
*' and
'int
*') which are pointers to non-overlapping address spaces
}}
178 b
= var_cmp
>= arg_gen
;
180 // expected-error
@-
2{{comparison between
('__constant int
*' and
'__generic int
*') which are pointers to non-overlapping address spaces
}}
184 b
= var_sub - arg_glob
;
186 // expected-error
@-
2{{arithmetic operation with operands of type
('__constant int
*' and
'__global int
*') which are pointers to non-overlapping address spaces
}}
189 b
= var_sub - arg_loc
;
191 // expected-error-re
@-
2{{arithmetic operation with operands of type
('__
{{global|constant
}} int
*' and
'__local int
*') which are pointers to non-overlapping address spaces
}}
194 b
= var_sub - arg_const
;
196 // expected-error-re
@-
2{{arithmetic operation with operands of type
('__
{{global|generic
}} int
*' and
'__constant int
*') which are pointers to non-overlapping address spaces
}}
199 b
= var_sub - arg_priv
;
201 // expected-error-re
@-
2{{arithmetic operation with operands of type
('__
{{global|constant
}} int
*' and
'int
*') which are pointers to non-overlapping address spaces
}}
204 b
= var_sub - arg_gen
;
206 // expected-error
@-
2{{arithmetic operation with operands of type
('__constant int
*' and
'__generic int
*') which are pointers to non-overlapping address spaces
}}
211 // expected-error-re
@-
2{{passing
'__
{{constant|generic
}} int
*' to parameter of type
'__global int
*' changes address space of pointer
}}
214 f_loc
(var_sub); // expected-error-re{{passing '__{{global|constant|generic}} int *' to parameter of type '__local int *' changes address space of pointer}}
218 // expected-error-re
@-
2{{passing
'__
{{global|generic
}} int
*' to parameter of type
'__constant int
*' changes address space of pointer
}}
221 f_priv
(var_sub); // expected-error-re{{passing '__{{global|constant|generic}} int *' to parameter of type 'int *' changes address space of pointer}}
225 // expected-error
@-
2{{passing
'__constant int
*' to parameter of type
'__generic int
*' changes address space of pointer
}}