aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-07-27 14:49:06 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-07-27 14:49:06 +0000
commit81a12b7606c58a7d6bea3151be426ef3e91b45ea (patch)
tree89f1e8bcacfb158e93c8b1fd41103eca189d1fef /gcc
parent270430ff3eb2632320372e6974ce9ef7038e31d2 (diff)
downloadgcc-81a12b7606c58a7d6bea3151be426ef3e91b45ea.zip
gcc-81a12b7606c58a7d6bea3151be426ef3e91b45ea.tar.gz
gcc-81a12b7606c58a7d6bea3151be426ef3e91b45ea.tar.bz2
Use static_assert for STATIC_ASSERT for C++11 onwards
C++11 has a static_assert (COND, MESSAGE) which gives more readable error messages for STATIC_ASSERT than our current implementation. This patch makes us use it if __cplusplus >= 201103L There's also a provisional static_assert (COND) in C++1z, but presumably we should wait until that one is fully standardized before using it. gcc/ChangeLog: * system.h (STATIC_ASSERT): Use static_assert if building with C++11 onwards. From-SVN: r238786
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/system.h7
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d2a2953..e00b2c4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2016-07-27 David Malcolm <dmalcolm@redhat.com>
+
+ * system.h (STATIC_ASSERT): Use static_assert if building
+ with C++11 onwards.
+
2016-07-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/72517
diff --git a/gcc/system.h b/gcc/system.h
index 78a7da6..8a17197 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,