Use gdb_static_assert in charset.c
authorChristian Biesinger <cbiesinger@google.com>
Mon, 7 Oct 2019 17:33:06 +0000 (12:33 -0500)
committerChristian Biesinger <cbiesinger@google.com>
Mon, 7 Oct 2019 17:49:26 +0000 (12:49 -0500)
It currently has a "manual" static assert.

gdb/ChangeLog:

2019-10-07  Christian Biesinger  <cbiesinger@google.com>

* charset.c (your_gdb_wchar_t_is_bogus): Replace with a
gdb_static_assert.

gdb/ChangeLog
gdb/charset.c

index daf79b05f7442a0cd1ff85492fba540ef4b6e49e..0f79f2d62bd2f03304e636829e1e346e1a545e7d 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-07  Christian Biesinger  <cbiesinger@google.com>
+
+       * charset.c (your_gdb_wchar_t_is_bogus): Replace with a
+       gdb_static_assert.
+
 2019-10-07  Weimin Pan  <weimin.pan@oracle.com>
 
        * ../Makefile.def (dependencies): Add all-libctf to all-gdb
index 9df46c0c74dd7d15b6ae83be91a2e59e1c73829e..73131651a6dbb652d925400a22d605353dcf51fd 100644 (file)
@@ -946,15 +946,9 @@ default_auto_wide_charset (void)
 #define ENDIAN_SUFFIX "LE"
 #endif
 
-/* The code below serves to generate a compile time error if
-   gdb_wchar_t type is not of size 2 nor 4, despite the fact that
-   macro __STDC_ISO_10646__ is defined.
-   This is better than a gdb_assert call, because GDB cannot handle
-   strings correctly if this size is different.  */
-
-extern char your_gdb_wchar_t_is_bogus[(sizeof (gdb_wchar_t) == 2
-                                      || sizeof (gdb_wchar_t) == 4)
-                                     ? 1 : -1];
+/* GDB cannot handle strings correctly if this size is different.  */
+
+gdb_static_assert (sizeof (gdb_wchar_t) == 2 || sizeof (gdb_wchar_t) == 4);
 
 /* intermediate_encoding returns the charset used internally by
    GDB to convert between target and host encodings. As the test above
This page took 0.029397 seconds and 4 git commands to generate.