blob: 050cbb4ed39f507005a934fce2e24f3acc092ff3 (
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
|
// { dg-do run }
#define vector __attribute__((vector_size(16)))
extern "C" void abort();
class Star
{
public:
inline vector float foo() const;
Star()
{
data.f[0] = 1.0; data.f[1] = 2.0; data.f[2] = 3.0, data.f[3] = 4.0;
}
private:
union {
float f[4];
vector float v;
} data;
friend vector float fTest(const Star &);
};
vector float Star::foo() const
{
return data.v;
}
vector float fTest(const Star & val)
{
vector float vf = val.foo();
return vf;
}
int main() {
Star s;
union u {
float f[4];
vector float v;
} data;
data.v = fTest(s);
for (int i=0 ; i < 4; i++)
if (data.f[i] != (float)(i+1))
abort();
return 0;
}
/* Ignore a warning that is irrelevant to the purpose of this test. */
/* { dg-prune-output ".*GCC vector returned by reference.*" } */
|