aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/cpp/embed-21.c
blob: e388b6ccac91309f158058d08997f7bd61696fbe (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 run } */
/* { dg-options "-O2 -Wno-psabi" } */
/* { dg-additional-options "-std=c23" { target c } } */

unsigned char a[] = {
#embed __FILE__
};
const unsigned char b[] = {
#embed __FILE__
};
unsigned char c[] = {
  0, 1, 2, 3, 4, 5, 6, 7,
#embed __FILE__ limit(128) suffix (,)
#embed __FILE__ limit(128) suffix (,)
#embed __FILE__
};
const unsigned char d[] = {
  0, 1, 2, 3, 4, 5, 6, 7,
#embed __FILE__ limit(128) suffix (,)
#embed __FILE__ limit(128) suffix (,)
#embed __FILE__
};
typedef char V __attribute__((vector_size (16), may_alias));
struct __attribute__((may_alias)) S { int a, b, c, d; };

__attribute__((noipa)) int
foo (V x, V y)
{
  return __builtin_memcmp (&x, &y, sizeof (x));
}

__attribute__((noipa)) int
bar (struct S x, struct S y)
{
  return x.a != y.a || x.b != y.b || x.c != y.c || x.d != y.d;
}

int
main ()
{
  if (a[0] != b[0]
      || a[42] != b[42]
      || a[sizeof (a) - 5] != b[sizeof (a) - 5]
      || a[sizeof (a) - 1] != b[sizeof (a) - 1])
    __builtin_abort ();
  if (foo (((V *) a)[0], ((V *) b)[0])
      || foo (((V *) a)[1], ((V *) b)[1])
      || foo (((V *) c)[8], ((V *) d)[8])
      || foo (((V *) c)[9], ((V *) d)[9]))
    __builtin_abort ();
  if (bar (((struct S *) a)[0], ((struct S *) b)[0])
      || bar (((struct S *) a)[1], ((struct S *) b)[1])
      || bar (((struct S *) c)[8], ((struct S *) d)[8])
      || bar (((struct S *) c)[9], ((struct S *) d)[9]))
    __builtin_abort ();
}