| 1 |
// { dg-do run } |
| 2 |
// { dg-options "-Wno-abi" } |
| 3 |
// PR c++/9844 |
| 4 |
|
| 5 |
extern "C" void abort(); |
| 6 |
|
| 7 |
#define vector __attribute__((vector_size(16))) |
| 8 |
|
| 9 |
class vector_holder |
| 10 |
{ |
| 11 |
char __attribute__((vector_size(16))) vec; |
| 12 |
char __attribute__((vector_size(16))) vec1; |
| 13 |
public: |
| 14 |
operator __attribute__((vector_size(16))) short (void) { |
| 15 |
return (__attribute__((vector_size(16))) short) vec; |
| 16 |
} |
| 17 |
|
| 18 |
operator __attribute__((vector_size(16))) unsigned int (void) { |
| 19 |
return (__attribute__((vector_size(16))) unsigned int) vec1; |
| 20 |
} |
| 21 |
|
| 22 |
vector_holder () { |
| 23 |
vec = (__attribute__((vector_size(16))) char) {'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', |
| 24 |
'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd'}; |
| 25 |
vec1 = (__attribute__((vector_size(16))) char) {'m', 'n', 'o', 'q', 'm', 'n', 'o', 'p', |
| 26 |
'm', 'n', 'o', 'q', 'm', 'n', 'o', 'p'}; |
| 27 |
} |
| 28 |
}; |
| 29 |
|
| 30 |
union u { |
| 31 |
char f[16]; |
| 32 |
vector unsigned int v; |
| 33 |
vector short vs; |
| 34 |
} data; |
| 35 |
|
| 36 |
|
| 37 |
vector_holder vh; |
| 38 |
|
| 39 |
int main() |
| 40 |
{ |
| 41 |
data.vs = (__attribute__((vector_size(16))) short) vh; |
| 42 |
if (data.f[0] != 'a' || data.f[15] != 'd') |
| 43 |
abort(); |
| 44 |
data.v = (__attribute__((vector_size(16))) unsigned int) vh; |
| 45 |
if (data.f[0] != 'm' || data.f[15] != 'p') |
| 46 |
abort(); |
| 47 |
|
| 48 |
return 0; |
| 49 |
} |
| 50 |
|
| 51 |
/* Ignore a warning that is irrelevant to the purpose of this test. */ |
| 52 |
/* { dg-prune-output ".*GCC vector returned by reference.*" } */ |
| 53 |
/* { dg-prune-output "changes the ABI" } */ |