aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/restrict-7.c
blob: 107371098b33b8547f52776c5c20fa72aa587172 (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
/* { dg-do run } */

extern void abort (void);

static inline __attribute__((always_inline)) void
copy(int *restrict a, int *restrict b)
{
  *b = *a;
  *a = 7;
}

void __attribute__((noinline))
floppy(int mat[static 2], unsigned idxs[static 3])
{
  for (int i = 0; i < 3; i++)
    copy(&mat[i%2], &mat[idxs[i]]);
}

int main()
{
  int mat[2] = {10, 20};
  unsigned idxs[3] = {1, 0, 1};
  floppy(mat, idxs);
  if (mat[0] != 7 || mat[1] != 10)
    abort ();
  return 0;
}