view gcc/testsuite/g++.dg/ext/flexary.h @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +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;