[1/6] Introduce __decl_is_flex_array macro

Message ID 20230710150454.5490-2-cristian@rodriguez.im
State New
Headers
Series Support use of -fstrict-flex-arrays in user code |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 fail Testing failed

Commit Message

Cristian Rodríguez July 10, 2023, 3:04 p.m. UTC
  Currently it is not possible to safely build user code
with GCC-13 -fstrict-flex-arrays due to the library
use of legacy fake flexible arrays and zero-length array gcc extension.

This commit introduces a __decl_is_flex_array macro intended to
grandfather-in this uses without modifying the relevant definitions.

Signed-off-by: Cristian Rodríguez <cristian@rodriguez.im>
---
 misc/sys/cdefs.h | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 90c21e2703..183cc5e2c9 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -720,4 +720,10 @@  _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+#if __glibc_has_attribute (__strict_flex_array__)
+#define __decl_is_flex_array __attribute__ ((__strict_flex_array__(0)))
+#else
+#define __decl_is_flex_array
+#endif
+
 #endif	 /* sys/cdefs.h */