[cfe-dev] [PATCH] libstdc++: Support std::is_aggregate on clang++ (was clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7)

Jonathan Wakely via cfe-dev cfe-dev at lists.llvm.org
Wed Aug 9 14:41:11 PDT 2017


On 02/08/17 00:05 +0900, Katsuhiko Nishimra wrote:
>On Mon, Jul 31, 2017 at 03:53:42PM +0100, Jonathan Wakely wrote:
>> This __has_bultin check only exists for Clang, so should be replaced
>> by the correct __is_identifier check, not left there in addition to
>> it.
>
>I see. Actually I've guessed so, and thank you for clarifying it.
>I'm attaching a replacing patch. Please take a look at it.

Thanks, I've committed this to GCC trunk and will backport it to the
gcc-7-branch after the GCC 7.2 release (which is due any day now).

I've also committed the attached patch which changes our feature
detection for a __has_unique_object_representations builtin, as I
expect that will also need to use __is_identifier if/when Clang
supports it.

Tested powerpc64le-linux, and also tested using Clang version 5.0.0
(trunk 307530) to confirm that __is_aggregate is correctly detected
and std::is_aggregate is defined.

>From 1b22cc531027832cf1eb50b73354f1730edbba54 Mon Sep 17 00:00:00 2001
>From: Katsuhiko Nishimra <ktns.87 at gmail.com>
>Date: Tue, 1 Aug 2017 20:36:58 +0900
>Subject: [PATCH] libstdc++: Support std::is_aggregate on clang++
>
>Currently, libstdc++ tries to detect __is_aggregate built-in macro using
>__has_builtin, but this fails on clang++ because __has_builtin on
>clang++ detects only built-in functions, not built-in macros. This patch
>adds a test using __is_identifier. Tested with clang++
>6.0.0-svn309616-1~exp1 and g++ 7.1.0-11 on Debian unstable.
>---
> libstdc++-v3/include/std/type_traits | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
>index 390b6f40a..ee9c75baf 100644
>--- a/libstdc++-v3/include/std/type_traits
>+++ b/libstdc++-v3/include/std/type_traits
>@@ -2894,9 +2894,9 @@ template <typename _From, typename _To>
> 
> #if __GNUC__ >= 7
> # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
>-#elif defined __has_builtin
>+#elif defined(__is_identifier)
> // For non-GNU compilers:
>-# if __has_builtin(__is_aggregate)
>+# if ! __is_identifier(__is_aggregate)
> #  define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
> # endif
> #endif
>-- 
>2.13.3
>



-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 1706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170809/60b90aa0/attachment.bin>


More information about the cfe-dev mailing list