public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Support std::is_aggregate on clang++ (was [cfe-dev] clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7)
@ 2017-07-27  7:27 Katsuhiko Nishimra
  2017-07-31 14:53 ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: Katsuhiko Nishimra @ 2017-07-27  7:27 UTC (permalink / raw)
  To: gcc-patches, libstdc++; +Cc: cfe-dev

From 56c4a18d0d8c8ce7aa1239880138775e4db06645 Mon Sep 17 00:00:00 2001
From: Katsuhiko Nishimra <ktns.87@gmail.com>
Date: Thu, 27 Jul 2017 16:03:54 +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 on clang++
5.0.0-svn308422-1~exp1 and g++ 7.1.0-10 from Debian unstable.
---
 libstdc++-v3/include/std/type_traits | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 390b6f40a..e7ec402fb 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -2894,6 +2894,11 @@ template <typename _From, typename _To>
 
 #if __GNUC__ >= 7
 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
+#elif defined(__is_identifier)
+// For clang
+# if ! __is_identifier(__is_aggregate)
+#  define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
+# endif
 #elif defined __has_builtin
 // For non-GNU compilers:
 # if __has_builtin(__is_aggregate)
-- 
2.13.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] libstdc++: Support std::is_aggregate on clang++ (was [cfe-dev] clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7)
  2017-07-27  7:27 [PATCH] libstdc++: Support std::is_aggregate on clang++ (was [cfe-dev] clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7) Katsuhiko Nishimra
@ 2017-07-31 14:53 ` Jonathan Wakely
  2017-07-31 15:14   ` Tim Song
  2017-08-01 15:06   ` Katsuhiko Nishimra
  0 siblings, 2 replies; 6+ messages in thread
From: Jonathan Wakely @ 2017-07-31 14:53 UTC (permalink / raw)
  To: Katsuhiko Nishimra; +Cc: gcc-patches, libstdc++, cfe-dev

On 27/07/17 16:27 +0900, Katsuhiko Nishimra wrote:
From 56c4a18d0d8c8ce7aa1239880138775e4db06645 Mon Sep 17 00:00:00 2001
>From: Katsuhiko Nishimra <ktns.87@gmail.com>
>Date: Thu, 27 Jul 2017 16:03:54 +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 on clang++
>5.0.0-svn308422-1~exp1 and g++ 7.1.0-10 from Debian unstable.
>---
> libstdc++-v3/include/std/type_traits | 5 +++++
> 1 file changed, 5 insertions(+)
>
>diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
>index 390b6f40a..e7ec402fb 100644
>--- a/libstdc++-v3/include/std/type_traits
>+++ b/libstdc++-v3/include/std/type_traits
>@@ -2894,6 +2894,11 @@ template <typename _From, typename _To>
>
> #if __GNUC__ >= 7
> # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
>+#elif defined(__is_identifier)
>+// For clang
>+# if ! __is_identifier(__is_aggregate)
>+#  define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
>+# endif
> #elif defined __has_builtin
> // For non-GNU compilers:
> # if __has_builtin(__is_aggregate)

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] libstdc++: Support std::is_aggregate on clang++ (was [cfe-dev] clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7)
  2017-07-31 14:53 ` Jonathan Wakely
@ 2017-07-31 15:14   ` Tim Song
  2017-07-31 17:23     ` Tim Song
  2017-08-01 15:06   ` Katsuhiko Nishimra
  1 sibling, 1 reply; 6+ messages in thread
From: Tim Song @ 2017-07-31 15:14 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Katsuhiko Nishimra, gcc-patches, libstdc++, cfe-dev

On Mon, Jul 31, 2017 at 10:53 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
> On 27/07/17 16:27 +0900, Katsuhiko Nishimra wrote:
>>
>> From 56c4a18d0d8c8ce7aa1239880138775e4db06645 Mon Sep 17 00:00:00 2001
>> From: Katsuhiko Nishimra <ktns.87@gmail.com>
>> Date: Thu, 27 Jul 2017 16:03:54 +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 on clang++
>> 5.0.0-svn308422-1~exp1 and g++ 7.1.0-10 from Debian unstable.
>> ---
>> libstdc++-v3/include/std/type_traits | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/libstdc++-v3/include/std/type_traits
>> b/libstdc++-v3/include/std/type_traits
>> index 390b6f40a..e7ec402fb 100644
>> --- a/libstdc++-v3/include/std/type_traits
>> +++ b/libstdc++-v3/include/std/type_traits
>> @@ -2894,6 +2894,11 @@ template <typename _From, typename _To>
>>
>> #if __GNUC__ >= 7
>> # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
>> +#elif defined(__is_identifier)
>> +// For clang
>> +# if ! __is_identifier(__is_aggregate)
>> +#  define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
>> +# endif
>> #elif defined __has_builtin
>> // For non-GNU compilers:
>> # if __has_builtin(__is_aggregate)
>
>
> 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] libstdc++: Support std::is_aggregate on clang++ (was [cfe-dev] clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7)
  2017-07-31 15:14   ` Tim Song
@ 2017-07-31 17:23     ` Tim Song
  0 siblings, 0 replies; 6+ messages in thread
From: Tim Song @ 2017-07-31 17:23 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Katsuhiko Nishimra, gcc-patches, libstdc++, cfe-dev

On Mon, Jul 31, 2017 at 11:13 AM, Tim Song <t.canens.cpp@gmail.com> wrote:
>
> 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] libstdc++: Support std::is_aggregate on clang++ (was [cfe-dev] clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7)
  2017-07-31 14:53 ` Jonathan Wakely
  2017-07-31 15:14   ` Tim Song
@ 2017-08-01 15:06   ` Katsuhiko Nishimra
  2017-08-09 23:17     ` Jonathan Wakely
  1 sibling, 1 reply; 6+ messages in thread
From: Katsuhiko Nishimra @ 2017-08-01 15:06 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-patches, libstdc++, cfe-dev


[-- Attachment #1.1: Type: text/plain, Size: 339 bytes --]

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.


[-- Attachment #1.2: 0001-libstdc-Support-std-is_aggregate-on-clang.patch --]
[-- Type: text/x-diff, Size: 1260 bytes --]

From 1b22cc531027832cf1eb50b73354f1730edbba54 Mon Sep 17 00:00:00 2001
From: Katsuhiko Nishimra <ktns.87@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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] libstdc++: Support std::is_aggregate on clang++ (was [cfe-dev] clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7)
  2017-08-01 15:06   ` Katsuhiko Nishimra
@ 2017-08-09 23:17     ` Jonathan Wakely
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2017-08-09 23:17 UTC (permalink / raw)
  To: Katsuhiko Nishimra; +Cc: gcc-patches, libstdc++, cfe-dev

[-- Attachment #1: Type: text/plain, Size: 2176 bytes --]

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@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
>




[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1706 bytes --]

commit 1b00aa3825ea05fea071f31d29aafff71a002c53
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Aug 9 19:07:28 2017 +0100

    Fix test for __has_unique_object_representations support in Clang
    
    	* include/std/type_traits (_GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP):
    	Replace with _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP and use
    	__is_identifier to set it.

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index ee9c75b..f021c42 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -2873,14 +2873,16 @@ template <typename _Base, typename _Derived>
 template <typename _From, typename _To>
   inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
 
-#ifdef __has_builtin
-# if !__has_builtin(__has_unique_object_representations)
-// Try not to break non-GNU compilers that don't support the built-in:
-#  define _GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP 1
+#if __GNUC__ >= 7
+# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
+#elif defined(__is_identifier)
+// For non-GNU compilers:
+# if ! __is_identifier(__has_unique_object_representations)
+#  define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
 # endif
 #endif
 
-#ifndef _GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP
+#ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
 # define __cpp_lib_has_unique_object_representations 201606
   /// has_unique_object_representations
   template<typename _Tp>
@@ -2890,7 +2892,7 @@ template <typename _From, typename _To>
       )>
     { };
 #endif
-#undef _GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP
+#undef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
 
 #if __GNUC__ >= 7
 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-08-09 21:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-27  7:27 [PATCH] libstdc++: Support std::is_aggregate on clang++ (was [cfe-dev] clang++: std::is_aggregate unusable with clang-5.0/libstdc++-7) Katsuhiko Nishimra
2017-07-31 14:53 ` Jonathan Wakely
2017-07-31 15:14   ` Tim Song
2017-07-31 17:23     ` Tim Song
2017-08-01 15:06   ` Katsuhiko Nishimra
2017-08-09 23:17     ` Jonathan Wakely

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).