public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] <sys/cdefs.h>: Decay expression passed to fallback
@ 2023-08-07 11:51 Sebastian Huber
0 siblings, 0 replies; only message in thread
From: Sebastian Huber @ 2023-08-07 11:51 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b12934540f17ba7c22923940e48bfbf02d0ae082
commit b12934540f17ba7c22923940e48bfbf02d0ae082
Author: John Baldwin <jhb@FreeBSD.org>
Date: Thu Jan 26 16:28:22 2023 -0800
<sys/cdefs.h>: Decay expression passed to fallback
version of __generic()
This ensures that __generic() more closely matches _Generic() when
using the fallback version when _Generic() is not available (such as
GCC).
Co-authored by: jrtc27
Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D38215
Diff:
---
newlib/libc/include/sys/cdefs.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index 720e70092..808498c50 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -328,6 +328,9 @@
* __generic(). Unlike _Generic(), this macro can only distinguish
* between a single type, so it requires nested invocations to
* distinguish multiple cases.
+ *
+ * Note that the comma operator is used to force expr to decay in
+ * order to match _Generic().
*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
@@ -337,7 +340,7 @@
#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
#define __generic(expr, t, yes, no) \
__builtin_choose_expr( \
- __builtin_types_compatible_p(__typeof(expr), t), yes, no)
+ __builtin_types_compatible_p(__typeof((0, (expr))), t), yes, no)
#endif
/*
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-07 11:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 11:51 [newlib-cygwin] <sys/cdefs.h>: Decay expression passed to fallback Sebastian Huber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).