view gcc/testsuite/gcc.dg/torture/restrict-7.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line source

/* { 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;
}