2016-12-07 Thomas Preud'homme <thomas.preudhomme@arm.com>
[official-gcc.git] / gcc / testsuite / g++.dg / parse / offsetof9.C
blobefc103837f9d2626894c948d42dd97d0f841cbfb
1 /* PR c/32041 */
2 /* { dg-do run } */
4 struct S
6   int c;
7   struct { float f; } sa[2];
8 };
10 char a[__builtin_offsetof (S, sa->f)
11        == __builtin_offsetof (S, sa[0].f) ? 1 : -1];
13 template <int N>
14 struct T
16   int c[N];
17   struct { float f; } sa[N];
18   static int foo () { return __builtin_offsetof (T, sa->f); }
19   static int bar () { return __builtin_offsetof (T, sa[0].f); }
22 char b[__builtin_offsetof (T<5>, sa->f)
23        == __builtin_offsetof (T<5>, sa[0].f) ? 1 : -1];
25 int
26 main ()
28   if (T<1>::foo () != T<1>::bar ())
29     __builtin_abort ();
30   if (T<7>::foo () != T<7>::bar ())
31     __builtin_abort ();