Debian Codegraph @

gcc/testsuite/g++.dg/ext/attribute-test-1.C

raw
1 // { dg-do run }
2 // { dg-options "" }
3 // PR c++/13989
4
5 extern "C" void abort();
6
7 typedef unsigned uint32_t __attribute__((mode (__SI__)));
8
9 #define vector __attribute__((vector_size(16)))
10
11 struct Constants {
12 inline vector uint32_t deadbeef(void) const {
13 return (vector uint32_t){0xdeadbeef, 0xabababab, 0x55555555, 0x12345678};
14 };
15 };
16
17 inline vector uint32_t const_deadbeef(Constants &C)
18 {
19 return C.deadbeef();
20 }
21
22 union u {
23 uint32_t f[4];
24 vector uint32_t v;
25 } data;
26
27 int main()
28 {
29 Constants c;
30 data.v = const_deadbeef(c);
31
32 if (data.f[0] != 0xdeadbeef || data.f[1] != 0xabababab
33 || data.f[2] != 0x55555555 || data.f[3] != 0x12345678)
34 abort();
35
36 return 0;
37 }
38
39 /* Ignore a warning that is irrelevant to the purpose of this test. */
40 /* { dg-prune-output ".*GCC vector returned by reference.*" } */
41 /* { dg-prune-output "changes the ABI" } */