Redefine gdb_static_assert as static_assert
authorSimon Marchi <simon.marchi@ericsson.com>
Tue, 5 Dec 2017 21:15:08 +0000 (16:15 -0500)
committerSimon Marchi <simon.marchi@ericsson.com>
Tue, 5 Dec 2017 21:15:09 +0000 (16:15 -0500)
Since we use C++11, we can use static_assert instead doing the trick
that makes a negative-sized array if the expression is false.
static_assert is built in the language and gives clearer error messages.

To avoid modifying the usages of gdb_static_assert, redefine
gdb_static_assert in terms of static_assert, passing an empty message.
If we want to add an assert with a message, it's always possible to use
static_assert directly.

gdb/ChangeLog:

* common/gdb_assert.h (gdb_static_assert): Redefine using
static_assert.

gdb/ChangeLog
gdb/common/gdb_assert.h

index 524eef3..ef0c4bd 100644 (file)
@@ -1,5 +1,10 @@
 2017-12-05  Simon Marchi  <simon.marchi@ericsson.com>
 
+       * common/gdb_assert.h (gdb_static_assert): Redefine using
+       static_assert.
+
+2017-12-05  Simon Marchi  <simon.marchi@ericsson.com>
+
        * ada-lang.c (ada_collect_symbol_completion_matches): Remove
        unused variables.
        (ada_is_redundant_range_encoding): Likewise.
index 5de9d3f..20825c8 100644 (file)
@@ -22,8 +22,7 @@
 /* A static assertion.  This will cause a compile-time error if EXPR,
    which must be a compile-time constant, is false.  */
 
-#define gdb_static_assert(expr) \
-  extern int never_defined_just_used_for_checking[(expr) ? 1 : -1]
+#define gdb_static_assert(expr) static_assert (expr, "")
 
 /* PRAGMATICS: "gdb_assert.h":gdb_assert() is a lower case (rather
    than upper case) macro since that provides the closest fit to the