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

From 56c4a18d0d8c8ce7aa1239880138775e4db06645 Mon Sep 17 00:00:00 2001

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 on clang++
5.0.0-svn308422-1~exp1 and g++ 7.1.0-10 from Debian unstable.

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.

https://clang.llvm.org/docs/LanguageExtensions.html#checks-for-type-trait-primitives
seems to suggest using __has_extension instead.

Hmm, that doesn't work. Oh well.

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.

0001-libstdc-Support-std-is_aggregate-on-clang.patch (1.23 KB)

By the way, Isn't it a bug? I've also confirmed both
__has_extension(is_aggregate) and __has_extension(__is_aggregate)
returns 0 on clang 6.0.0-svn309616-1~exp1.

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.

patch.txt (1.67 KB)