aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/pr89505.c
blob: 6fca475ad9d6c4aebe78771b7a28dc7eebba7d10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* { dg-do run } */

struct S { int i; void *p; int j; };
int a;
int __attribute__((noinline))
foo (struct S * __restrict p, int q)
{
  int *x = &p->j;
  if (q)
    x = &a;
  p->j = 1;
  *x = 2;
  return p->j;
}

int main()
{
  struct S s;
  if (foo (&s, 0) != 2)
    __builtin_abort ();
  return 0;
}