blob: 4cb580ebc9a71561faef8d0042f7264cf5f9661f (
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
|
/* { dg-do compile { target i?86-*-linux* x86_64-*-linux* } } */
/* { dg-options "-O2" } */
typedef __SIZE_TYPE__ size_t;
extern void abort (void);
extern char buf[0x40000000];
void
test1 (size_t x)
{
char *p = &buf[8];
size_t i;
for (i = 0; i < x; ++i)
p = p + 4;
if (__builtin_object_size (p, 0) != sizeof (buf) - 8)
abort ();
}
void
test2 (size_t x)
{
char *p = &buf[8];
size_t i;
for (i = 0; i < x; ++i)
p = p + 4;
if (__builtin_object_size (p, 1) != sizeof (buf) - 8)
abort ();
}
void
test3 (size_t x)
{
char *p = &buf[8];
size_t i;
for (i = 0; i < x; ++i)
p = p + 4;
if (__builtin_object_size (p, 2) != 0)
abort ();
}
void
test4 (size_t x)
{
char *p = &buf[8];
size_t i;
for (i = 0; i < x; ++i)
p = p + 4;
if (__builtin_object_size (p, 3) != 0)
abort ();
}
/* { dg-final { scan-assembler-not "abort" } } */
|