1 // RUN: clang-cc -fsyntax-only -verify %s
3 #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
5 typedef struct P { int i; float f; } PT;
6 struct external_sun3_core
17 x = offsetof(struct external_sun3_core, c_regs);
18 x = __builtin_offsetof(struct external_sun3_core, X[42].f);
20 x = __builtin_offsetof(struct external_sun3_core, X[42].f2); // expected-error {{no member named 'f2'}}
21 x = __builtin_offsetof(int, X[42].f2); // expected-error {{offsetof requires struct}}
23 int a[__builtin_offsetof(struct external_sun3_core, X) == 4 ? 1 : -1];
24 int b[__builtin_offsetof(struct external_sun3_core, X[42]) == 340 ? 1 : -1];
25 int c[__builtin_offsetof(struct external_sun3_core, X[42].f2) == 344 ? 1 : -1]; // expected-error {{no member named 'f2'}}
31 int v1 = offsetof (struct s1, a) == 0 ? 0 : f();
34 int v2 = (int)(&((struct s2 *) 0)->a) == 0 ? 0 : f();
37 int v3 = __builtin_offsetof(struct s3, a) == 0 ? 0 : f();
41 unsigned char sun_len;
45 int a[__builtin_offsetof(struct sockaddr_un, sun_path[len+1])];
49 union x {struct {int x;};};
50 int x[__builtin_offsetof(union x, x)];