* [2.26 COMMITTED] Do not use generic selection in C++ mode
@ 2017-01-01 0:00 Florian Weimer
0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2017-01-01 0:00 UTC (permalink / raw)
To: libc-stable
The logic to protect the use of generic selection (_Generic) does not
check for C or C++ mode, however, generic selection is a C-only
feature.
Tested for powerpc64le.
* misc/sys/cdefs.h (__HAVE_GENERIC_SELECTION): Define to 0, if
in C++ mode.
(cherry picked from commit 6913ad65e00bb32417ad39c41d292b976171e27e)
2017-08-18 Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
* misc/sys/cdefs.h (__HAVE_GENERIC_SELECTION): Define to 0, if
in C++ mode.
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 06523bfe9c..0c808216a4 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -464,17 +464,18 @@
# define __glibc_macro_warning(msg)
#endif
-/* Support for generic selection (ISO C11) is available in GCC since
- version 4.9. Previous versions do not provide generic selection,
- even though they might set __STDC_VERSION__ to 201112L, when in
- -std=c11 mode. Thus, we must check for !defined __GNUC__ when
- testing __STDC_VERSION__ for generic selection support.
+/* Generic selection (ISO C11) is a C-only feature, available in GCC
+ since version 4.9. Previous versions do not provide generic
+ selection, even though they might set __STDC_VERSION__ to 201112L,
+ when in -std=c11 mode. Thus, we must check for !defined __GNUC__
+ when testing __STDC_VERSION__ for generic selection support.
On the other hand, Clang also defines __GNUC__, so a clang-specific
check is required to enable the use of generic selection. */
-#if __GNUC_PREREQ (4, 9) \
- || __glibc_clang_has_extension (c_generic_selections) \
- || (!defined __GNUC__ && defined __STDC_VERSION__ \
- && __STDC_VERSION__ >= 201112L)
+#if !defined __cplusplus \
+ && (__GNUC_PREREQ (4, 9) \
+ || __glibc_clang_has_extension (c_generic_selections) \
+ || (!defined __GNUC__ && defined __STDC_VERSION__ \
+ && __STDC_VERSION__ >= 201112L))
# define __HAVE_GENERIC_SELECTION 1
#else
# define __HAVE_GENERIC_SELECTION 0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-08-21 12:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-01 0:00 [2.26 COMMITTED] Do not use generic selection in C++ mode Florian Weimer
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).