0002-Do-not-use-generic-selection-in-C-mode.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From bb21afc362a3ecba07ab386a0bc4385e75fbd4b5 Mon Sep 17 00:00:00 2001
  2. From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
  3. Date: Mon, 14 Aug 2017 17:51:51 -0300
  4. Subject: [PATCH] Do not use generic selection in C++ mode
  5. The logic to protect the use of generic selection (_Generic) does not
  6. check for C or C++ mode, however, generic selection is a C-only
  7. feature.
  8. Tested for powerpc64le.
  9. * misc/sys/cdefs.h (__HAVE_GENERIC_SELECTION): Define to 0, if
  10. in C++ mode.
  11. (cherry picked from commit 6913ad65e00bb32417ad39c41d292b976171e27e)
  12. [Romain rebase on glibc 2.26]
  13. Signed-off-by: Romain Naour <romain.naour@gmail.com>
  14. ---
  15. misc/sys/cdefs.h | 19 ++++++++++---------
  16. 1 file changed, 10 insertions(+), 9 deletions(-)
  17. diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
  18. index 06523bf..0c80821 100644
  19. --- a/misc/sys/cdefs.h
  20. +++ b/misc/sys/cdefs.h
  21. @@ -464,17 +464,18 @@
  22. # define __glibc_macro_warning(msg)
  23. #endif
  24. -/* Support for generic selection (ISO C11) is available in GCC since
  25. - version 4.9. Previous versions do not provide generic selection,
  26. - even though they might set __STDC_VERSION__ to 201112L, when in
  27. - -std=c11 mode. Thus, we must check for !defined __GNUC__ when
  28. - testing __STDC_VERSION__ for generic selection support.
  29. +/* Generic selection (ISO C11) is a C-only feature, available in GCC
  30. + since version 4.9. Previous versions do not provide generic
  31. + selection, even though they might set __STDC_VERSION__ to 201112L,
  32. + when in -std=c11 mode. Thus, we must check for !defined __GNUC__
  33. + when testing __STDC_VERSION__ for generic selection support.
  34. On the other hand, Clang also defines __GNUC__, so a clang-specific
  35. check is required to enable the use of generic selection. */
  36. -#if __GNUC_PREREQ (4, 9) \
  37. - || __glibc_clang_has_extension (c_generic_selections) \
  38. - || (!defined __GNUC__ && defined __STDC_VERSION__ \
  39. - && __STDC_VERSION__ >= 201112L)
  40. +#if !defined __cplusplus \
  41. + && (__GNUC_PREREQ (4, 9) \
  42. + || __glibc_clang_has_extension (c_generic_selections) \
  43. + || (!defined __GNUC__ && defined __STDC_VERSION__ \
  44. + && __STDC_VERSION__ >= 201112L))
  45. # define __HAVE_GENERIC_SELECTION 1
  46. #else
  47. # define __HAVE_GENERIC_SELECTION 0
  48. --
  49. 2.9.5