annotate gcc/testsuite/g++.dg/ext/flexary.h @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Definitions of helper macros for tests of flexible array members.
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 #if __cplusplus < 201102L
kono
parents:
diff changeset
4 # define _CAT(x, y) x ## y
kono
parents:
diff changeset
5 # define CAT(x, y) _CAT (x, y)
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 // Generate a struct with a unique name containing a bitfield
kono
parents:
diff changeset
8 // of size that must evaluate to a non-zero value, otherwise
kono
parents:
diff changeset
9 // generate a compiler error.
kono
parents:
diff changeset
10 # define ASSERT(expr) \
kono
parents:
diff changeset
11 struct CAT (FAM_Assert, __LINE__) { unsigned asrt: 0 != (expr); }
kono
parents:
diff changeset
12 #else
kono
parents:
diff changeset
13 // In C++ 11 and beyond, use static_assert.
kono
parents:
diff changeset
14 # define ASSERT(expr) static_assert (expr, #expr)
kono
parents:
diff changeset
15 #endif
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 // Macro to verify that a flexible array member is allocated
kono
parents:
diff changeset
18 // at the very end of the containing struct.
kono
parents:
diff changeset
19 #define ASSERT_AT_END(T, m) \
kono
parents:
diff changeset
20 ASSERT (__builtin_offsetof (T, m) == sizeof (T))
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 typedef __SIZE_TYPE__ size_t;