1 // RUN
: %clang_cc1 %s -verify -pedantic -fsyntax-only
3 typedef unsigned char uchar
;
4 typedef unsigned char uchar2 __attribute__
((ext_vector_type(2)));
6 typedef char char2 __attribute__
((ext_vector_type(2)));
7 typedef char char3 __attribute__
((ext_vector_type(3)));
9 typedef int int2 __attribute__
((ext_vector_type(2)));
11 typedef float float2 __attribute__
((ext_vector_type(2)));
13 // ** Positive tests
**
15 // all scalars
, but widths do not match.
16 int ptest01
(char C
, char X
, int Y
)
21 char ptest02
(int C
, char X
, char Y
)
26 // scalar condition and mixed-width vectors and scalars
27 int2 ptest03
(char C
, char X
, int2 Y
)
33 char2 ptest04
(char2 X
, char2 Y
, char2 C
)
38 // vector condition and mixed scalar operands
39 int2 ptest05
(int2 C
, int X
, char Y
)
44 // vector condition and matching scalar operands
45 float2 ptest06
(int2 C
, float X
, float Y
)
50 // vector condition and mixed scalar operands
51 float2 ptest07
(int2 C
, int X
, float Y
)
56 // vector condition and mixed scalar and vector operands
57 float2 ptest08
(int2 C
, int X
, float2 Y
)
62 // Actual comparison expression
63 float2 ptest09
(float2 A
, float2 B
, float2 C
, float2 D
)
68 // ** Negative tests
**
70 int2 ntest01
(char2 C
, int X
, int Y
)
72 return C ? X
: Y
; // expected-error {{vector condition type 'char2' (vector of 2 'char' values) and result type (vector of 2 'int' values) do not have elements of the same size}}
75 int2 ntest02
(char2 C
, int2 X
, int2 Y
)
77 return C ? X
: Y
; // expected-error {{vector condition type 'char2' (vector of 2 'char' values) and result type 'int2' (vector of 2 'int' values) do not have elements of the same size}}
80 uchar2 ntest03
(int2 C
, uchar X
, uchar Y
)
82 return C ? X
: Y
; // expected-error {{vector condition type 'int2' (vector of 2 'int' values) and result type (vector of 2 'unsigned char' values) do not have elements of the same size}}
85 float2 ntest04
(int2 C
, int2 X
, float2 Y
)
87 return C ? X
: Y
; // expected-error {{implicit conversions between vector types ('int2' (vector of 2 'int' values) and 'float2' (vector of 2 'float' values)) are not permitted}}
90 float2 ntest05
(int2 C
, int2 X
, float Y
)
92 return C ? X
: Y
; // expected-error {{scalar operand type has greater rank than the type of the vector element. ('int2' (vector of 2 'int' values) and 'float'}}
95 char2 ntest06
(int2 C
, char2 X
, char2 Y
)
97 return C ? X
: Y
; // expected-error {{vector condition type 'int2' (vector of 2 'int' values) and result type 'char2' (vector of 2 'char' values) do not have elements of the same size}}
100 float ntest07
(float C
, float X
, float Y
)
102 return C ? X
: Y
; // expected-error {{used type 'float' where floating point type is not allowed}}
105 float2 ntest08
(float2 C
, float2 X
, float2 Y
)
107 return C ? X
: Y
; // expected-error {{used type 'float2' (vector of 2 'float' values) where floating point type is not allowed}}
110 // Trying to create a int2 vector out of pointers.
111 int2 ntest09
(int2 C
, global int
*X
, global int
*Y
)
113 return C ? X
: Y
; // expected-error {{used type '__global int *' where integer or floating point type is required}}
116 char3 ntest10
(char C
, char3 X
, char2 Y
)
118 return C ? X
: Y
; // expected-error {{implicit conversions between vector types ('char3' (vector of 3 'char' values) and 'char2' (vector of 2 'char' values)) are not permitted}}
121 char3 ntest11
(char2 C
, char3 X
, char Y
)
123 return C ? X
: Y
; // expected-error {{vector condition type 'char2' (vector of 2 'char' values) and result type 'char3' (vector of 3 'char' values) do not have the same number of elements}}
129 unsigned int ntest12
(int2 C
)
131 return
(unsigned int
)(C ? foo1
: foo2
); // expected-error {{taking address of function is not allowed}} expected-error {{taking address of function is not allowed}}