view gcc/testsuite/g++.dg/ext/flexary.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

// Definitions of helper macros for tests of flexible array members.

#if __cplusplus < 201102L
#  define _CAT(x, y)  x ## y
#  define CAT(x, y)  _CAT (x, y)

// Generate a struct with a unique name containing a bitfield
// of size that must evaluate to a non-zero value, otherwise
// generate a compiler error.
#  define ASSERT(expr)                                                  \
  struct CAT (FAM_Assert, __LINE__) { unsigned asrt: 0 != (expr); }
#else
// In C++ 11 and beyond, use static_assert.
# define ASSERT(expr) static_assert (expr, #expr)
#endif

// Macro to verify that a flexible array member is allocated
// at the very end of the containing struct.
#define ASSERT_AT_END(T, m)                             \
  ASSERT (__builtin_offsetof (T, m) == sizeof (T))

typedef __SIZE_TYPE__ size_t;