blob: d1b3dc3c5f8c50772c4d870c3d0661ea905da989 (
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
55
56
57
58
59
60
61
62
63
64
|
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* { dg-require-effective-target trampolines } */
int main()
{
int n = 1;
struct foo { char x[++n]; } bar(void) { struct foo r; return r; }
if (2 != n)
__builtin_abort();
if (2 != sizeof(bar()))
__builtin_abort();
n = 1;
struct bar { char x[++n]; } (*bar2p)(void);
struct bar bar2(void) { struct bar r; return r; }
bar2p = &bar2;
if (2 != n)
__builtin_abort();
if (2 != sizeof((*bar2p)()))
__builtin_abort();
n = 1;
struct str { char x[++n]; } *bar3(void)
{
struct str* s = __builtin_malloc(sizeof(struct str));
if (!s)
__builtin_abort();
struct str t;
*s = t;
return s;
}
if (2 != n)
__builtin_abort();
struct str* p;
if (2 != sizeof(*(p = bar3())))
__builtin_abort();
__builtin_free(p);
n = 1;
struct { char x[++n]; } *bar4(void) { }
if (2 != n)
__builtin_abort();
#if 0
// UB
if (2 != sizeof(*bar4()))
__builtin_abort();
#endif
}
|