Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2023-01-27 03:28:22 +0300
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-08-07 14:45:03 +0300
commitb12934540f17ba7c22923940e48bfbf02d0ae082 (patch)
tree09c4969e36dcfc23caee6ce20ca220f45bab8fc7 /newlib/libc
parent3b4f6217c371cf70d5ec5137436cfa5892bb45e8 (diff)
<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
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/include/sys/cdefs.h5
1 files changed, 4 insertions, 1 deletions
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
/*