summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/20101013-1.c
blob: 7d477aff046bfdb652db9abd0caa1f1721bdc372 (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
/* PR rtl-optimization/45912 */

extern void abort (void);

static void* __attribute__((noinline,noclone))
get_addr_base_and_unit_offset (void *base, long long *i)
{
  *i = 0;
  return base;
}

static void* __attribute__((noinline,noclone))
build_int_cst (void *base, long long offset)
{
  if (offset != 4)
    abort ();

  return base;
}

static void* __attribute__((noinline,noclone))
build_ref_for_offset (void *base, long long offset)
{
  long long base_offset;
  base = get_addr_base_and_unit_offset (base, &base_offset);
  return build_int_cst (base, base_offset + offset / 8);
}

int
main (void)
{
  void *ret = build_ref_for_offset ((void *)0, 32);
  if (ret != (void *)0)
    abort ();
  return 0;
}