diff mbox series

libiberty: Don't use VLAs if __STDC_NO_VLA__ is non-zero

Message ID 20190530205055.21215-1-mforney@mforney.org
State New
Headers show
Series libiberty: Don't use VLAs if __STDC_NO_VLA__ is non-zero | expand

Commit Message

Michael Forney May 30, 2019, 8:50 p.m. UTC
VLAs are optional in C11, and an implementation that does not support
them will define __STDC_NO_VLA__ to 1.

2019-05-30  Michael Forney  <mforney@mforney.org>

	* cp-demangle.c: Don't define CP_DYNAMIC_ARRAYS if __STDC_NO_VLA__
	is non-zero.
---
 libiberty/cp-demangle.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jeff Law May 31, 2019, 6:26 p.m. UTC | #1
On 5/30/19 2:50 PM, Michael Forney wrote:
> VLAs are optional in C11, and an implementation that does not support
> them will define __STDC_NO_VLA__ to 1.
> 
> 2019-05-30  Michael Forney  <mforney@mforney.org>
> 
> 	* cp-demangle.c: Don't define CP_DYNAMIC_ARRAYS if __STDC_NO_VLA__
> 	is non-zero.
THanks.  I've installed this on the trunk.  Though I must admit some
surprise, what compiler are you using that defines STDC_NO_VLA? :-)

jeff
diff mbox series

Patch

diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 4e5b733b548..aa78c86dd44 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -192,9 +192,9 @@  static void d_init_info (const char *, int, size_t, struct d_info *);
 #else
 #ifdef __STDC__
 #ifdef __STDC_VERSION__
-#if __STDC_VERSION__ >= 199901L
+#if __STDC_VERSION__ >= 199901L && !__STDC_NO_VLA__
 #define CP_DYNAMIC_ARRAYS
-#endif /* __STDC__VERSION >= 199901L */
+#endif /* __STDC_VERSION__ >= 199901L && !__STDC_NO_VLA__ */
 #endif /* defined (__STDC_VERSION__) */
 #endif /* defined (__STDC__) */
 #endif /* ! defined (__GNUC__) */