PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / c90-const-expr-9.c
blob4793a14b6c4e61f1beaf6b50f8d89c346629ebc6
1 /* Test for constant expressions: __builtin_offsetof allowed in
2 integer constant expressions but not traditional offsetof
3 expansion. */
4 /* Origin: Joseph Myers <joseph@codesourcery.com> */
5 /* { dg-do compile } */
6 /* { dg-options "-std=iso9899:1990 -pedantic-errors -ftrack-macro-expansion=0" } */
8 struct s {
9 int a;
12 struct t {
13 struct s a;
14 int b[2];
17 __extension__ typedef __SIZE_TYPE__ size_t;
18 __extension__ typedef __UINTPTR_TYPE__ uintptr_t;
20 #define old_offsetof(TYPE, MEMBER) ((size_t) (uintptr_t) &((TYPE *)0)->MEMBER)
22 enum e {
23 E1 = old_offsetof (struct s, a), /* { dg-error "constant" } */
24 E2 = old_offsetof (struct t, a.a), /* { dg-error "constant" } */
25 E3 = old_offsetof (struct t, b[1]), /* { dg-error "constant" } */
26 E4 = __builtin_offsetof (struct s, a),
27 E5 = __builtin_offsetof (struct t, a.a),
28 E6 = __builtin_offsetof (struct t, b[1])