Chris Lattner | 3b427b3 | 2007-10-11 00:18:28 +0000 | [diff] [blame^] | 1 | // RUN: clang -fsyntax-only -verify %s |
Chris Lattner | d3fb6ad | 2007-08-30 17:51:09 +0000 | [diff] [blame] | 2 | |
| 3 | #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) |
| 4 | |
| 5 | typedef struct P { int i; float f; } PT; |
| 6 | struct external_sun3_core |
| 7 | { |
| 8 | unsigned c_regs; |
| 9 | |
| 10 | PT X[100]; |
| 11 | |
| 12 | }; |
| 13 | |
| 14 | void swap() |
| 15 | { |
| 16 | int x; |
| 17 | x = offsetof(struct external_sun3_core, c_regs); |
| 18 | x = __builtin_offsetof(struct external_sun3_core, X[42].f); |
| 19 | |
| 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}} |
| 22 | } |
| 23 | |