]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Simplify STATIC_ASSERT macro.
authorMartin Liška <mliska@suse.cz>
Thu, 5 May 2022 12:18:58 +0000 (14:18 +0200)
committerMartin Liska <mliska@suse.cz>
Mon, 9 May 2022 12:09:01 +0000 (14:09 +0200)
For C++, use always __static_assert and for C, use the negative array
index.

gcc/ChangeLog:

* basic-block.h (STATIC_ASSERT): Use normal STATIC_ASSERT.
* system.h (STATIC_ASSERT): Define as static_assert for C++
and fallback to array index in C.

gcc/basic-block.h
gcc/system.h

index e3fff1f6975d5a8104f3fd0e8eba6042df7cb1d2..21a9b24dbf9e6d376b0961b6088f8bd2a54223bf 100644 (file)
@@ -158,10 +158,7 @@ struct GTY((chain_next ("%h.next_bb"), chain_prev ("%h.prev_bb"))) basic_block_d
 /* This ensures that struct gimple_bb_info is smaller than
    struct rtl_bb_info, so that inlining the former into basic_block_def
    is the better choice.  */
-typedef int __assert_gimple_bb_smaller_rtl_bb
-              [(int) sizeof (struct rtl_bb_info)
-               - (int) sizeof (struct gimple_bb_info)];
-
+STATIC_ASSERT (sizeof (rtl_bb_info) >= sizeof (gimple_bb_info));
 
 #define BB_FREQ_MAX 10000
 
index 1121af485a4025113c293e19bcf85f99bc490fab..1c783c5331d4fbeff85b2f6f7aa8a2c4e7884c09 100644 (file)
@@ -835,8 +835,7 @@ extern void fancy_abort (const char *, int, const char *)
 #define STATIC_CONSTANT_P(X) (false && (X))
 #endif
 
-/* static_assert (COND, MESSAGE) is available in C++11 onwards.  */
-#if __cplusplus >= 201103L
+#ifdef __cplusplus
 #define STATIC_ASSERT(X) \
   static_assert ((X), #X)
 #else