public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Suppress pedantic warnings about __int128
@ 2021-07-16  7:41 Jonathan Wakely
  2021-07-16  8:27 ` Jakub Jelinek
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2021-07-16  7:41 UTC (permalink / raw)
  To: libstdc++, gcc-patches

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

With -std=c++NN -pedantic -Wsystem-headers there are warnings about the
use of __int128, which can be suppressed using diagnostic pragmas.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/cpp_type_traits.h: Add diagnostic pragmas around
	uses of non-standard integer types.
	* include/bits/functional_hash.h: Likewise.
	* include/bits/iterator_concepts.h: Likewise.
	* include/bits/max_size_type.h: Likewise.
	* include/bits/std_abs.h: Likewise.
	* include/bits/stl_algobase.h: Likewise.
	* include/bits/uniform_int_dist.h: Likewise.
	* include/ext/numeric_traits.h: Likewise.
	* include/std/type_traits: Likewise.

Tested powerpc64le-linux. Committed to trunk.


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

commit c1676651b6c417e8f2b276a28199d76943834277
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Jul 15 15:36:34 2021

    libstdc++: Suppress pedantic warnings about __int128
    
    With -std=c++NN -pedantic -Wsystem-headers there are warnings about the
    use of __int128, which can be suppressed using diagnostic pragmas.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/cpp_type_traits.h: Add diagnostic pragmas around
            uses of non-standard integer types.
            * include/bits/functional_hash.h: Likewise.
            * include/bits/iterator_concepts.h: Likewise.
            * include/bits/max_size_type.h: Likewise.
            * include/bits/std_abs.h: Likewise.
            * include/bits/stl_algobase.h: Likewise.
            * include/bits/uniform_int_dist.h: Likewise.
            * include/ext/numeric_traits.h: Likewise.
            * include/std/type_traits: Likewise.

diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h
index ca0d68c29de..8f8dd817dc2 100644
--- a/libstdc++-v3/include/bits/cpp_type_traits.h
+++ b/libstdc++-v3/include/bits/cpp_type_traits.h
@@ -266,6 +266,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef __true_type __type;	\
     };
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+
 #ifdef __GLIBCXX_TYPE_INT_N_0
 __INT_N(__GLIBCXX_TYPE_INT_N_0)
 #endif
@@ -279,6 +282,8 @@ __INT_N(__GLIBCXX_TYPE_INT_N_2)
 __INT_N(__GLIBCXX_TYPE_INT_N_3)
 #endif
 
+#pragma GCC diagnostic pop
+
 #undef __INT_N
 
   //
diff --git a/libstdc++-v3/include/bits/functional_hash.h b/libstdc++-v3/include/bits/functional_hash.h
index 7be8ebfa2d3..78e3644bc74 100644
--- a/libstdc++-v3/include/bits/functional_hash.h
+++ b/libstdc++-v3/include/bits/functional_hash.h
@@ -171,6 +171,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// Explicit specialization for unsigned long long.
   _Cxx_hashtable_define_trivial_hash(unsigned long long)
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+
 #ifdef __GLIBCXX_TYPE_INT_N_0
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0 unsigned)
@@ -188,6 +191,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3 unsigned)
 #endif
 
+#pragma GCC diagnostic pop
+
 #undef _Cxx_hashtable_define_trivial_hash
 
   struct _Hash_impl
diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h
index c273056c204..97c0b80a507 100644
--- a/libstdc++-v3/include/bits/iterator_concepts.h
+++ b/libstdc++-v3/include/bits/iterator_concepts.h
@@ -553,6 +553,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     class __max_diff_type;
     class __max_size_type;
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+
     template<typename _Tp>
       concept __is_signed_int128
 #if __SIZEOF_INT128__
@@ -569,6 +572,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	= false;
 #endif
 
+#pragma GCC diagnostic pop
+
     template<typename _Tp>
       concept __cv_bool = same_as<const volatile _Tp, const volatile bool>;
 
diff --git a/libstdc++-v3/include/bits/max_size_type.h b/libstdc++-v3/include/bits/max_size_type.h
index 153b1bff5f4..24237cc57de 100644
--- a/libstdc++-v3/include/bits/max_size_type.h
+++ b/libstdc++-v3/include/bits/max_size_type.h
@@ -417,7 +417,10 @@ namespace ranges
 #endif
 
 #if __SIZEOF_INT128__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
       using __rep = unsigned __int128;
+#pragma GCC diagnostic pop
 #else
       using __rep = unsigned long long;
 #endif
@@ -771,7 +774,10 @@ namespace ranges
       static constexpr bool is_integer = true;
       static constexpr bool is_exact = true;
 #if __SIZEOF_INT128__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
       static_assert(same_as<_Sp::__rep, unsigned __int128>);
+#pragma GCC diagnostic pop
       static constexpr int digits = 129;
 #else
       static_assert(same_as<_Sp::__rep, unsigned long long>);
diff --git a/libstdc++-v3/include/bits/std_abs.h b/libstdc++-v3/include/bits/std_abs.h
index ae6bfc1b1ac..c65ebb66439 100644
--- a/libstdc++-v3/include/bits/std_abs.h
+++ b/libstdc++-v3/include/bits/std_abs.h
@@ -80,6 +80,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { return __builtin_fabsl(__x); }
 #endif
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+
 #if defined(__GLIBCXX_TYPE_INT_N_0)
   inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0
   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
@@ -104,6 +107,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { return __x < 0 ? -__x : __x; }
 #endif
 
+#pragma GCC diagnostic pop
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 } // extern "C"++"
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index d001b5f9dae..7f920dbdbf7 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -1013,6 +1013,9 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
   inline _GLIBCXX_CONSTEXPR unsigned long long
   __size_to_integer(unsigned long long __n) { return __n; }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+
 #if defined(__GLIBCXX_TYPE_INT_N_0)
   inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0
   __size_to_integer(__GLIBCXX_TYPE_INT_N_0 __n) { return __n; }
@@ -1038,6 +1041,8 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
   __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_3 __n) { return __n; }
 #endif
 
+#pragma GCC diagnostic pop
+
   inline _GLIBCXX_CONSTEXPR long long
   __size_to_integer(float __n) { return (long long)__n; }
   inline _GLIBCXX_CONSTEXPR long long
diff --git a/libstdc++-v3/include/bits/uniform_int_dist.h b/libstdc++-v3/include/bits/uniform_int_dist.h
index 2d83524caf6..8ee33450fa1 100644
--- a/libstdc++-v3/include/bits/uniform_int_dist.h
+++ b/libstdc++-v3/include/bits/uniform_int_dist.h
@@ -299,6 +299,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if defined __UINT64_TYPE__ && defined __UINT32_TYPE__
 #if __SIZEOF_INT128__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
 	    if _GLIBCXX17_CONSTEXPR (__urngrange == __UINT64_MAX__)
 	      {
 		// __urng produces values that use exactly 64-bits,
@@ -307,6 +309,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		__ret = _S_nd<unsigned __int128>(__urng, __u64erange);
 	      }
 	    else
+#pragma GCC diagnostic pop
 #endif
 	    if _GLIBCXX17_CONSTEXPR (__urngrange == __UINT32_MAX__)
 	      {
diff --git a/libstdc++-v3/include/ext/numeric_traits.h b/libstdc++-v3/include/ext/numeric_traits.h
index a81fa6f0d85..0dc1bc61f3e 100644
--- a/libstdc++-v3/include/ext/numeric_traits.h
+++ b/libstdc++-v3/include/ext/numeric_traits.h
@@ -123,9 +123,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
 #if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
   // In strict modes __is_integer<__int128> is false,
   // but we still want to define __numeric_traits_integer<__int128>.
   _GLIBCXX_INT_N_TRAITS(__int128, 128)
+#pragma GCC diagnostic pop
 #endif
 
 #undef _GLIBCXX_INT_N_TRAITS
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index cccc6eed763..91d65234f23 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -347,6 +347,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __is_integral_helper<unsigned long long>
     : public true_type { };
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+
   // Conditionalizing on __STRICT_ANSI__ here will break any port that
   // uses one of these types for size_t.
 #if defined(__GLIBCXX_TYPE_INT_N_0)
@@ -385,6 +388,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
     : public true_type { };
 #endif
+#pragma GCC diagnostic pop
   /// @endcond
 
   /// is_integral
@@ -617,6 +621,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp, typename... _Types>
     using __is_one_of = __or_<is_same<_Tp, _Types>...>;
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+
   // Check if a type is one of the signed integer types.
   template<typename _Tp>
     using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>,
@@ -654,6 +661,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  , unsigned __GLIBCXX_TYPE_INT_N_3
 #endif
 	  >;
+#pragma GCC diagnostic pop
 
   // Check if a type is one of the signed or unsigned integer types.
   template<typename _Tp>
@@ -1717,6 +1725,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __make_unsigned<long long>
     { typedef unsigned long long __type; };
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+
 #if defined(__GLIBCXX_TYPE_INT_N_0)
   template<>
     struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0>
@@ -1738,6 +1749,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; };
 #endif
 
+#pragma GCC diagnostic pop
+
   // Select between integral and enum: not possible to be both.
   template<typename _Tp,
 	   bool _IsInt = is_integral<_Tp>::value,
@@ -1873,6 +1886,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __make_signed<unsigned long long>
     { typedef signed long long __type; };
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+
 #if defined(__GLIBCXX_TYPE_INT_N_0)
   template<>
     struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0>
@@ -1894,6 +1910,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { typedef __GLIBCXX_TYPE_INT_N_3 __type; };
 #endif
 
+#pragma GCC diagnostic pop
+
   // Select between integral and enum: not possible to be both.
   template<typename _Tp,
 	   bool _IsInt = is_integral<_Tp>::value,

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

* Re: [committed] libstdc++: Suppress pedantic warnings about __int128
  2021-07-16  7:41 [committed] libstdc++: Suppress pedantic warnings about __int128 Jonathan Wakely
@ 2021-07-16  8:27 ` Jakub Jelinek
  2021-07-16  8:29   ` Jakub Jelinek
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Jelinek @ 2021-07-16  8:27 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

On Fri, Jul 16, 2021 at 08:41:06AM +0100, Jonathan Wakely via Gcc-patches wrote:
> --- a/libstdc++-v3/include/bits/max_size_type.h
> +++ b/libstdc++-v3/include/bits/max_size_type.h
> @@ -417,7 +417,10 @@ namespace ranges
>  #endif
>  
>  #if __SIZEOF_INT128__
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wpedantic"
>        using __rep = unsigned __int128;
> +#pragma GCC diagnostic pop

At least in simple cases like this, wouldn't
	using __rep = __extension__ unsigned __int128;
be smaller?  And it should be more targetted, wouldn't disable
other pedantic warnings but about __int128.

	Jakub


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

* Re: [committed] libstdc++: Suppress pedantic warnings about __int128
  2021-07-16  8:27 ` Jakub Jelinek
@ 2021-07-16  8:29   ` Jakub Jelinek
  2021-07-16  8:38     ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Jelinek @ 2021-07-16  8:29 UTC (permalink / raw)
  To: Jonathan Wakely, libstdc++, gcc-patches

On Fri, Jul 16, 2021 at 10:27:09AM +0200, Jakub Jelinek via Gcc-patches wrote:
> On Fri, Jul 16, 2021 at 08:41:06AM +0100, Jonathan Wakely via Gcc-patches wrote:
> > --- a/libstdc++-v3/include/bits/max_size_type.h
> > +++ b/libstdc++-v3/include/bits/max_size_type.h
> > @@ -417,7 +417,10 @@ namespace ranges
> >  #endif
> >  
> >  #if __SIZEOF_INT128__
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wpedantic"
> >        using __rep = unsigned __int128;
> > +#pragma GCC diagnostic pop
> 
> At least in simple cases like this, wouldn't
> 	using __rep = __extension__ unsigned __int128;

__extension__ using __rep = unsigned __int128;
actually (now tested).

	Jakub


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

* Re: [committed] libstdc++: Suppress pedantic warnings about __int128
  2021-07-16  8:29   ` Jakub Jelinek
@ 2021-07-16  8:38     ` Jonathan Wakely
  2021-07-16  8:39       ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2021-07-16  8:38 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Jonathan Wakely, libstdc++, gcc-patches

On Fri, 16 Jul 2021, 09:30 Jakub Jelinek via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:

> On Fri, Jul 16, 2021 at 10:27:09AM +0200, Jakub Jelinek via Gcc-patches
> wrote:
> > On Fri, Jul 16, 2021 at 08:41:06AM +0100, Jonathan Wakely via
> Gcc-patches wrote:
> > > --- a/libstdc++-v3/include/bits/max_size_type.h
> > > +++ b/libstdc++-v3/include/bits/max_size_type.h
> > > @@ -417,7 +417,10 @@ namespace ranges
> > >  #endif
> > >
> > >  #if __SIZEOF_INT128__
> > > +#pragma GCC diagnostic push
> > > +#pragma GCC diagnostic ignored "-Wpedantic"
> > >        using __rep = unsigned __int128;
> > > +#pragma GCC diagnostic pop
> >
> > At least in simple cases like this, wouldn't
> >       using __rep = __extension__ unsigned __int128;
>
> __extension__ using __rep = unsigned __int128;
> actually (now tested).
>

Ah, thanks. I didn't find the right syntax, and I know __extension__
doesn't work in other cases, like quad float literals, so I assumed it
doesn't work here. I suppose the literals don't work because the warning
comes from the processor, which doesn't understand __extension__ (and also
ignores the diagnostic pragma).





>         Jakub
>
>

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

* Re: [committed] libstdc++: Suppress pedantic warnings about __int128
  2021-07-16  8:38     ` Jonathan Wakely
@ 2021-07-16  8:39       ` Jonathan Wakely
  2021-07-16 11:29         ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2021-07-16  8:39 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Jonathan Wakely, libstdc++, gcc-patches

On Fri, 16 Jul 2021, 09:38 Jonathan Wakely, <jwakely.gcc@gmail.com> wrote:

>
>
> On Fri, 16 Jul 2021, 09:30 Jakub Jelinek via Libstdc++, <
> libstdc++@gcc.gnu.org> wrote:
>
>> On Fri, Jul 16, 2021 at 10:27:09AM +0200, Jakub Jelinek via Gcc-patches
>> wrote:
>> > On Fri, Jul 16, 2021 at 08:41:06AM +0100, Jonathan Wakely via
>> Gcc-patches wrote:
>> > > --- a/libstdc++-v3/include/bits/max_size_type.h
>> > > +++ b/libstdc++-v3/include/bits/max_size_type.h
>> > > @@ -417,7 +417,10 @@ namespace ranges
>> > >  #endif
>> > >
>> > >  #if __SIZEOF_INT128__
>> > > +#pragma GCC diagnostic push
>> > > +#pragma GCC diagnostic ignored "-Wpedantic"
>> > >        using __rep = unsigned __int128;
>> > > +#pragma GCC diagnostic pop
>> >
>> > At least in simple cases like this, wouldn't
>> >       using __rep = __extension__ unsigned __int128;
>>
>> __extension__ using __rep = unsigned __int128;
>> actually (now tested).
>>
>
> Ah, thanks. I didn't find the right syntax, and I know __extension__
> doesn't work in other cases, like quad float literals, so I assumed it
> doesn't work here. I suppose the literals don't work because the warning
> comes from the processor, which doesn't understand __extension__ (and also
> ignores the diagnostic pragma).
>

That grammar for a using-declaration makes no sense at all btw ;-)

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

* Re: [committed] libstdc++: Suppress pedantic warnings about __int128
  2021-07-16  8:39       ` Jonathan Wakely
@ 2021-07-16 11:29         ` Jonathan Wakely
  2021-07-16 13:02           ` [PATCH] libstdc++: Use __extension__ instead of diagnostic pragmas (was: Suppress pedantic warnings about __int128) Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2021-07-16 11:29 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Jakub Jelinek, libstdc++, gcc-patches

On Fri, 16 Jul 2021 at 09:40, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
>
>
> On Fri, 16 Jul 2021, 09:38 Jonathan Wakely, <jwakely.gcc@gmail.com> wrote:
>>
>>
>>
>> On Fri, 16 Jul 2021, 09:30 Jakub Jelinek via Libstdc++, <libstdc++@gcc.gnu.org> wrote:
>>>
>>> On Fri, Jul 16, 2021 at 10:27:09AM +0200, Jakub Jelinek via Gcc-patches wrote:
>>> > On Fri, Jul 16, 2021 at 08:41:06AM +0100, Jonathan Wakely via Gcc-patches wrote:
>>> > > --- a/libstdc++-v3/include/bits/max_size_type.h
>>> > > +++ b/libstdc++-v3/include/bits/max_size_type.h
>>> > > @@ -417,7 +417,10 @@ namespace ranges
>>> > >  #endif
>>> > >
>>> > >  #if __SIZEOF_INT128__
>>> > > +#pragma GCC diagnostic push
>>> > > +#pragma GCC diagnostic ignored "-Wpedantic"
>>> > >        using __rep = unsigned __int128;
>>> > > +#pragma GCC diagnostic pop
>>> >
>>> > At least in simple cases like this, wouldn't
>>> >       using __rep = __extension__ unsigned __int128;
>>>
>>> __extension__ using __rep = unsigned __int128;
>>> actually (now tested).
>>
>>
>> Ah, thanks. I didn't find the right syntax, and I know __extension__ doesn't work in other cases, like quad float literals, so I assumed it doesn't work here. I suppose the literals don't work because the warning comes from the processor, which doesn't understand __extension__ (and also ignores the diagnostic pragma).
>
>
> That grammar for a using-declaration makes no sense at all btw ;-)

Hmm, in fact it seems that we can just use the __uint128_t typedef
instead, which doesn't give a pedwarn:

  using __rep = __uint128_t;

Is that typedef always available if __int128 is? There's a comment in
gcc/c-family/c-common.c that I don't understand:

#if HOST_BITS_PER_WIDE_INT >= 64
  /* Note that this is different than the __int128 type that's part of
     the generic __intN support.  */
  if (targetm.scalar_mode_supported_p (TImode))
    lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
                       TYPE_DECL,
                       get_identifier ("__int128_t"),
                       intTI_type_node));
#endif

They are the same type in C++, so what is "different"? Is it possible
for __int128 to be different from a TImode integer?

We can still use __extension__ elsewhere, for defining explicit
specializations using the non-standard integers, e.g.

#define __INT_N(TYPE)                  \
+  __extension__                                \
  template<>                           \
    struct __is_integer<TYPE>          \
    {                                  \
      enum { __value = 1 };            \
      typedef __true_type __type;      \
    };


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

* [PATCH] libstdc++: Use __extension__ instead of diagnostic pragmas (was: Suppress pedantic warnings about __int128)
  2021-07-16 11:29         ` Jonathan Wakely
@ 2021-07-16 13:02           ` Jonathan Wakely
  2021-07-16 14:39             ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2021-07-16 13:02 UTC (permalink / raw)
  To: libstdc++; +Cc: Jakub Jelinek, gcc-patches

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

On Fri, 16 Jul 2021 at 12:29, Jonathan Wakely wrote:
> Hmm, in fact it seems that we can just use the __uint128_t typedef
> instead, which doesn't give a pedwarn:
>
>   using __rep = __uint128_t;
>
> Is that typedef always available if __int128 is? There's a comment in
> gcc/c-family/c-common.c that I don't understand:
>
> #if HOST_BITS_PER_WIDE_INT >= 64
>   /* Note that this is different than the __int128 type that's part of
>      the generic __intN support.  */
>   if (targetm.scalar_mode_supported_p (TImode))
>     lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
>                        TYPE_DECL,
>                        get_identifier ("__int128_t"),
>                        intTI_type_node));
> #endif
>
> They are the same type in C++, so what is "different"? Is it possible
> for __int128 to be different from a TImode integer?

As discussed on IRC, I'm going to add a configure check that __int128
and __int128_t are the same, and similarly for the unsigned versions.
That will allow us to use __int128_t and __uint128_t to avoid the
warnings (assuming GCC doesn't change to warn consistently for the
non-standard typedefs as well as the non-standard types).

For now, I'll just use __extension__ consistently everywhere. I'm
testing the attached patch that does that.

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

commit d74d80c850f70d68100336c5ba0c166e22bc5ef6
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jul 16 13:23:06 2021

    libstdc++: Use __extension__ instead of diagnostic pragmas
    
    This reverts c1676651b6c417e8f2b276a28199d76943834277 and uses the
    __extension__ keyword to prevent pedantic warnings instead of diagnostic
    pragmas.
    
    This also adds the __extension__ keyword in <limits> and <bits/random.h>
    where there are some more warnings that I missed in the previous commit.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/cpp_type_traits.h (__INT_N): Use __extension__
            instead of diagnostic pragmas.
            * include/bits/functional_hash.h: Likewise.
            * include/bits/iterator_concepts.h (__is_signed_int128)
            (__is_unsigned_int128): Likewise.
            * include/bits/max_size_type.h (__max_size_type): Likewise.
            (numeric_limits<__max_size_type>): Likewise.
            * include/bits/std_abs.h (abs): Likewise.
            * include/bits/stl_algobase.h (__size_to_integer): Likewise.
            * include/bits/uniform_int_dist.h (uniform_int_distribution):
            Likewise.
            * include/ext/numeric_traits.h (_GLIBCXX_INT_N_TRAITS):
            Likewise.
            * include/std/type_traits (__is_integral_helper<INT_N>)
            (__is_signed_integer, __is_unsigned_integer)
            (__make_unsigned<INT_N>, __make_signed<INT_N>): Likewise.
            * include/std/limits (__INT_N): Add __extension__ keyword.
            * include/bits/random.h (_Select_uint_least_t)
            (random_device): Likewise.

diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h
index 8f8dd817dc2..d9462209bc2 100644
--- a/libstdc++-v3/include/bits/cpp_type_traits.h
+++ b/libstdc++-v3/include/bits/cpp_type_traits.h
@@ -253,12 +253,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
 #define __INT_N(TYPE) 			\
+  __extension__				\
   template<>				\
     struct __is_integer<TYPE>		\
     {					\
       enum { __value = 1 };		\
       typedef __true_type __type;	\
     };					\
+  __extension__				\
   template<>				\
     struct __is_integer<unsigned TYPE>	\
     {					\
@@ -266,9 +268,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef __true_type __type;	\
     };
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-
 #ifdef __GLIBCXX_TYPE_INT_N_0
 __INT_N(__GLIBCXX_TYPE_INT_N_0)
 #endif
@@ -282,8 +281,6 @@ __INT_N(__GLIBCXX_TYPE_INT_N_2)
 __INT_N(__GLIBCXX_TYPE_INT_N_3)
 #endif
 
-#pragma GCC diagnostic pop
-
 #undef __INT_N
 
   //
diff --git a/libstdc++-v3/include/bits/functional_hash.h b/libstdc++-v3/include/bits/functional_hash.h
index 78e3644bc74..919faba778b 100644
--- a/libstdc++-v3/include/bits/functional_hash.h
+++ b/libstdc++-v3/include/bits/functional_hash.h
@@ -171,28 +171,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// Explicit specialization for unsigned long long.
   _Cxx_hashtable_define_trivial_hash(unsigned long long)
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-
 #ifdef __GLIBCXX_TYPE_INT_N_0
+  __extension__
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
+  __extension__
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0 unsigned)
 #endif
 #ifdef __GLIBCXX_TYPE_INT_N_1
+  __extension__
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1)
+  __extension__
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1 unsigned)
 #endif
 #ifdef __GLIBCXX_TYPE_INT_N_2
+  __extension__
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2)
+  __extension__
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2 unsigned)
 #endif
 #ifdef __GLIBCXX_TYPE_INT_N_3
+  __extension__
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3)
+  __extension__
   _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3 unsigned)
 #endif
 
-#pragma GCC diagnostic pop
-
 #undef _Cxx_hashtable_define_trivial_hash
 
   struct _Hash_impl
diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h
index 97c0b80a507..9c28ebfb345 100644
--- a/libstdc++-v3/include/bits/iterator_concepts.h
+++ b/libstdc++-v3/include/bits/iterator_concepts.h
@@ -553,9 +553,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     class __max_diff_type;
     class __max_size_type;
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-
+    __extension__
     template<typename _Tp>
       concept __is_signed_int128
 #if __SIZEOF_INT128__
@@ -564,6 +562,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	= false;
 #endif
 
+    __extension__
     template<typename _Tp>
       concept __is_unsigned_int128
 #if __SIZEOF_INT128__
@@ -572,8 +571,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	= false;
 #endif
 
-#pragma GCC diagnostic pop
-
     template<typename _Tp>
       concept __cv_bool = same_as<const volatile _Tp, const volatile bool>;
 
diff --git a/libstdc++-v3/include/bits/max_size_type.h b/libstdc++-v3/include/bits/max_size_type.h
index 24237cc57de..298a929db03 100644
--- a/libstdc++-v3/include/bits/max_size_type.h
+++ b/libstdc++-v3/include/bits/max_size_type.h
@@ -417,10 +417,8 @@ namespace ranges
 #endif
 
 #if __SIZEOF_INT128__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
+      __extension__
       using __rep = unsigned __int128;
-#pragma GCC diagnostic pop
 #else
       using __rep = unsigned long long;
 #endif
@@ -774,10 +772,7 @@ namespace ranges
       static constexpr bool is_integer = true;
       static constexpr bool is_exact = true;
 #if __SIZEOF_INT128__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-      static_assert(same_as<_Sp::__rep, unsigned __int128>);
-#pragma GCC diagnostic pop
+      static_assert(__extension__ same_as<_Sp::__rep, __uint128_t>);
       static constexpr int digits = 129;
 #else
       static_assert(same_as<_Sp::__rep, unsigned long long>);
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h
index 9e0359b8092..6d0e1544c90 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -101,7 +101,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #if __SIZEOF_INT128__ > __SIZEOF_LONG_LONG__
     template<int __s>
       struct _Select_uint_least_t<__s, 1>
-      { typedef unsigned __int128 type; };
+      { __extension__ typedef unsigned __int128 type; };
 #endif
 
     // Assume a != 0, a < m, c < m, x < m.
@@ -1663,7 +1663,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     void _M_init(const char*, size_t); // not exported from the shared library
 
-    union
+    __extension__ union
     {
       struct
       {
diff --git a/libstdc++-v3/include/bits/std_abs.h b/libstdc++-v3/include/bits/std_abs.h
index c65ebb66439..908d6bcd983 100644
--- a/libstdc++-v3/include/bits/std_abs.h
+++ b/libstdc++-v3/include/bits/std_abs.h
@@ -80,35 +80,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { return __builtin_fabsl(__x); }
 #endif
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-
 #if defined(__GLIBCXX_TYPE_INT_N_0)
-  inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0
+  __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0
   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_1)
-  inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1
+  __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1
   abs(__GLIBCXX_TYPE_INT_N_1 __x) { return __x >= 0 ? __x : -__x; }
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_2)
-  inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2
+  __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2
   abs(__GLIBCXX_TYPE_INT_N_2 __x) { return __x >= 0 ? __x : -__x; }
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_3)
-  inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3
+  __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3
   abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; }
 #endif
 
 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
-  inline _GLIBCXX_CONSTEXPR
+  __extension__ inline _GLIBCXX_CONSTEXPR
   __float128
   abs(__float128 __x)
   { return __x < 0 ? -__x : __x; }
 #endif
 
-#pragma GCC diagnostic pop
-
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 } // extern "C"++"
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index 7f920dbdbf7..d0c49628d7f 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -1013,36 +1013,31 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
   inline _GLIBCXX_CONSTEXPR unsigned long long
   __size_to_integer(unsigned long long __n) { return __n; }
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-
 #if defined(__GLIBCXX_TYPE_INT_N_0)
-  inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0
+  __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0
   __size_to_integer(__GLIBCXX_TYPE_INT_N_0 __n) { return __n; }
-  inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_0
+  __extension__ inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_0
   __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_0 __n) { return __n; }
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_1)
-  inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1
+  __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1
   __size_to_integer(__GLIBCXX_TYPE_INT_N_1 __n) { return __n; }
-  inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_1
+  __extension__ inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_1
   __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_1 __n) { return __n; }
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_2)
-  inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2
+  __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2
   __size_to_integer(__GLIBCXX_TYPE_INT_N_2 __n) { return __n; }
-  inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_2
+  __extension__ inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_2
   __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_2 __n) { return __n; }
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_3)
-  inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_3
+  __extension__ inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_3
   __size_to_integer(__GLIBCXX_TYPE_INT_N_3 __n) { return __n; }
-  inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3
+  __extension__ inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3
   __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_3 __n) { return __n; }
 #endif
 
-#pragma GCC diagnostic pop
-
   inline _GLIBCXX_CONSTEXPR long long
   __size_to_integer(float __n) { return (long long)__n; }
   inline _GLIBCXX_CONSTEXPR long long
@@ -1050,7 +1045,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
   inline _GLIBCXX_CONSTEXPR long long
   __size_to_integer(long double __n) { return (long long)__n; }
 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
-  inline _GLIBCXX_CONSTEXPR long long
+  __extension__ inline _GLIBCXX_CONSTEXPR long long
   __size_to_integer(__float128 __n) { return (long long)__n; }
 #endif
 
diff --git a/libstdc++-v3/include/bits/uniform_int_dist.h b/libstdc++-v3/include/bits/uniform_int_dist.h
index 8ee33450fa1..622b1fee91d 100644
--- a/libstdc++-v3/include/bits/uniform_int_dist.h
+++ b/libstdc++-v3/include/bits/uniform_int_dist.h
@@ -299,17 +299,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if defined __UINT64_TYPE__ && defined __UINT32_TYPE__
 #if __SIZEOF_INT128__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
 	    if _GLIBCXX17_CONSTEXPR (__urngrange == __UINT64_MAX__)
 	      {
 		// __urng produces values that use exactly 64-bits,
 		// so use 128-bit integers to downscale to desired range.
 		__UINT64_TYPE__ __u64erange = __uerange;
-		__ret = _S_nd<unsigned __int128>(__urng, __u64erange);
+		__ret = __extension__ _S_nd<unsigned __int128>(__urng,
+							       __u64erange);
 	      }
 	    else
-#pragma GCC diagnostic pop
 #endif
 	    if _GLIBCXX17_CONSTEXPR (__urngrange == __UINT32_MAX__)
 	      {
diff --git a/libstdc++-v3/include/ext/numeric_traits.h b/libstdc++-v3/include/ext/numeric_traits.h
index 0dc1bc61f3e..3ef0989fe74 100644
--- a/libstdc++-v3/include/ext/numeric_traits.h
+++ b/libstdc++-v3/include/ext/numeric_traits.h
@@ -93,12 +93,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Enable __numeric_traits_integer for types where the __is_integer_nonstrict
   // primary template doesn't give the right answer.
 #define _GLIBCXX_INT_N_TRAITS(T, WIDTH)			\
+  __extension__						\
   template<> struct __is_integer_nonstrict<T>		\
   {							\
     enum { __value = 1 };				\
     typedef std::__true_type __type;			\
     enum { __width = WIDTH };				\
   };							\
+  __extension__						\
   template<> struct __is_integer_nonstrict<unsigned T>	\
   {							\
     enum { __value = 1 };				\
@@ -123,12 +125,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
 #if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
   // In strict modes __is_integer<__int128> is false,
   // but we still want to define __numeric_traits_integer<__int128>.
   _GLIBCXX_INT_N_TRAITS(__int128, 128)
-#pragma GCC diagnostic pop
 #endif
 
 #undef _GLIBCXX_INT_N_TRAITS
diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits
index f2c20724f37..79aff3d93a4 100644
--- a/libstdc++-v3/include/std/limits
+++ b/libstdc++-v3/include/std/limits
@@ -1478,6 +1478,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
 #define __INT_N(TYPE, BITSIZE, EXT, UEXT)				\
+  __extension__								\
   template<>								\
     struct numeric_limits<TYPE>						\
     {									\
@@ -1546,6 +1547,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	= round_toward_zero; 						\
     }; 									\
 									\
+  __extension__								\
   template<>								\
     struct numeric_limits<unsigned TYPE>				\
     {									\
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 8d9c6394cd8..15ec83a06b8 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -347,48 +347,52 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __is_integral_helper<unsigned long long>
     : public true_type { };
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-
   // Conditionalizing on __STRICT_ANSI__ here will break any port that
   // uses one of these types for size_t.
 #if defined(__GLIBCXX_TYPE_INT_N_0)
+  __extension__
   template<>
     struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0>
     : public true_type { };
 
+  __extension__
   template<>
     struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0>
     : public true_type { };
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_1)
+  __extension__
   template<>
     struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1>
     : public true_type { };
 
+  __extension__
   template<>
     struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1>
     : public true_type { };
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_2)
+  __extension__
   template<>
     struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2>
     : public true_type { };
 
+  __extension__
   template<>
     struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2>
     : public true_type { };
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_3)
+  __extension__
   template<>
     struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3>
     : public true_type { };
 
+  __extension__
   template<>
     struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
     : public true_type { };
 #endif
-#pragma GCC diagnostic pop
   /// @endcond
 
   /// is_integral
@@ -621,10 +625,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp, typename... _Types>
     using __is_one_of = __or_<is_same<_Tp, _Types>...>;
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-
   // Check if a type is one of the signed integer types.
+  __extension__
   template<typename _Tp>
     using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>,
 	  signed char, signed short, signed int, signed long,
@@ -644,6 +646,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  >;
 
   // Check if a type is one of the unsigned integer types.
+  __extension__
   template<typename _Tp>
     using __is_unsigned_integer = __is_one_of<__remove_cv_t<_Tp>,
 	  unsigned char, unsigned short, unsigned int, unsigned long,
@@ -661,7 +664,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  , unsigned __GLIBCXX_TYPE_INT_N_3
 #endif
 	  >;
-#pragma GCC diagnostic pop
 
   // Check if a type is one of the signed or unsigned integer types.
   template<typename _Tp>
@@ -1725,32 +1727,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __make_unsigned<long long>
     { typedef unsigned long long __type; };
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-
 #if defined(__GLIBCXX_TYPE_INT_N_0)
+  __extension__
   template<>
     struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0>
     { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; };
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_1)
+  __extension__
   template<>
     struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1>
     { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; };
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_2)
+  __extension__
   template<>
     struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2>
     { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; };
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_3)
+  __extension__
   template<>
     struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3>
     { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; };
 #endif
 
-#pragma GCC diagnostic pop
-
   // Select between integral and enum: not possible to be both.
   template<typename _Tp,
 	   bool _IsInt = is_integral<_Tp>::value,
@@ -1886,32 +1887,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __make_signed<unsigned long long>
     { typedef signed long long __type; };
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-
 #if defined(__GLIBCXX_TYPE_INT_N_0)
+  __extension__
   template<>
     struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0>
     { typedef __GLIBCXX_TYPE_INT_N_0 __type; };
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_1)
+  __extension__
   template<>
     struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1>
     { typedef __GLIBCXX_TYPE_INT_N_1 __type; };
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_2)
+  __extension__
   template<>
     struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2>
     { typedef __GLIBCXX_TYPE_INT_N_2 __type; };
 #endif
 #if defined(__GLIBCXX_TYPE_INT_N_3)
+  __extension__
   template<>
     struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3>
     { typedef __GLIBCXX_TYPE_INT_N_3 __type; };
 #endif
 
-#pragma GCC diagnostic pop
-
   // Select between integral and enum: not possible to be both.
   template<typename _Tp,
 	   bool _IsInt = is_integral<_Tp>::value,

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

* Re: [PATCH] libstdc++: Use __extension__ instead of diagnostic pragmas (was: Suppress pedantic warnings about __int128)
  2021-07-16 13:02           ` [PATCH] libstdc++: Use __extension__ instead of diagnostic pragmas (was: Suppress pedantic warnings about __int128) Jonathan Wakely
@ 2021-07-16 14:39             ` Jonathan Wakely
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Wakely @ 2021-07-16 14:39 UTC (permalink / raw)
  To: libstdc++; +Cc: Jakub Jelinek, gcc-patches

On Fri, 16 Jul 2021 at 14:02, Jonathan Wakely wrote:
>
> On Fri, 16 Jul 2021 at 12:29, Jonathan Wakely wrote:
> > Hmm, in fact it seems that we can just use the __uint128_t typedef
> > instead, which doesn't give a pedwarn:
> >
> >   using __rep = __uint128_t;
> >
> > Is that typedef always available if __int128 is? There's a comment in
> > gcc/c-family/c-common.c that I don't understand:
> >
> > #if HOST_BITS_PER_WIDE_INT >= 64
> >   /* Note that this is different than the __int128 type that's part of
> >      the generic __intN support.  */
> >   if (targetm.scalar_mode_supported_p (TImode))
> >     lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
> >                        TYPE_DECL,
> >                        get_identifier ("__int128_t"),
> >                        intTI_type_node));
> > #endif
> >
> > They are the same type in C++, so what is "different"? Is it possible
> > for __int128 to be different from a TImode integer?
>
> As discussed on IRC, I'm going to add a configure check that __int128
> and __int128_t are the same, and similarly for the unsigned versions.
> That will allow us to use __int128_t and __uint128_t to avoid the
> warnings (assuming GCC doesn't change to warn consistently for the
> non-standard typedefs as well as the non-standard types).
>
> For now, I'll just use __extension__ consistently everywhere. I'm
> testing the attached patch that does that.

Pushed to trunk now.


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

end of thread, other threads:[~2021-07-16 14:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16  7:41 [committed] libstdc++: Suppress pedantic warnings about __int128 Jonathan Wakely
2021-07-16  8:27 ` Jakub Jelinek
2021-07-16  8:29   ` Jakub Jelinek
2021-07-16  8:38     ` Jonathan Wakely
2021-07-16  8:39       ` Jonathan Wakely
2021-07-16 11:29         ` Jonathan Wakely
2021-07-16 13:02           ` [PATCH] libstdc++: Use __extension__ instead of diagnostic pragmas (was: Suppress pedantic warnings about __int128) Jonathan Wakely
2021-07-16 14:39             ` 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).