aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp/embed-10.C
blob: 7ffcc2d2608ce56159200a474bf01852531a1974 (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
// { dg-do run { target c++23 } }
// { dg-options "--embed-dir=${srcdir}/c-c++-common/cpp/embed-dir" }

const unsigned char m[] = {
  #embed <magna-carta.txt> limit (136)
};

struct S
{
  S () : a {} {};
  template <typename ...T>
  int &operator[] (T... args)
  {
    int b[] = { args... };
    for (int i = 0; i < sizeof (b) / sizeof (b[0]); ++i)
      if (b[i] != m[i])
	return a[137];
    return a[sizeof (b) / sizeof (b[0])];
  }
  int a[138];
};

S s;

int
main ()
{
  if (&s[
      #embed <magna-carta.txt> limit (1)
	] != &s.a[1])
    __builtin_abort ();
  if (&s[
      #embed <magna-carta.txt> limit (6)
	] != &s.a[6])
    __builtin_abort ();
  if (&s[
      #embed <magna-carta.txt> limit (135)
	] != &s.a[135])
    __builtin_abort ();
}