diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d2a295352ffd..e00b2c4432f5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-07-27 David Malcolm + + * system.h (STATIC_ASSERT): Use static_assert if building + with C++11 onwards. + 2016-07-27 Richard Biener PR tree-optimization/72517 diff --git a/gcc/system.h b/gcc/system.h index 78a7da63d8eb..8a1719748196 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -752,9 +752,14 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; #define STATIC_CONSTANT_P(X) (false && (X)) #endif -/* Until we can use C++11's static_assert. */ +/* static_assert (COND, MESSAGE) is available in C++11 onwards. */ +#if __cplusplus >= 201103L +#define STATIC_ASSERT(X) \ + static_assert ((X), #X) +#else #define STATIC_ASSERT(X) \ typedef int assertion1[(X) ? 1 : -1] ATTRIBUTE_UNUSED +#endif /* Provide a fake boolean type. We make no attempt to use the C99 _Bool, as it may not be available in the bootstrap compiler,