public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Disable -Wctor-dtor-privacy warnings for some standard types
@ 2019-06-14 14:05 Jonathan Wakely
  2019-06-15 10:53 ` Daniel Krügler
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2019-06-14 14:05 UTC (permalink / raw)
  To: libstdc++, gcc-patches

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

These types are not constructible by design, so we never want warnings
for them, even with -Wsystem-headers.

	* include/experimental/type_traits (experimental::nonesuch): Use
	pragma to disable -Wctor-dtor-privacy warnings.
	* include/std/type_traits (__is_convertible_helper<From, To, false>)
	(__is_nt_convertible_helper<From, To, false>, __nonesuch): Likewise.

Tested x86_64-linux, committed to trunk.



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

commit bde783a93449ed52ffa301c338b23cd57df0cc77
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Jun 14 14:03:20 2019 +0000

    Disable -Wctor-dtor-privacy warnings for some standard types
    
            * include/experimental/type_traits (experimental::nonesuch): Use
            pragma to disable -Wctor-dtor-privacy warnings.
            * include/std/type_traits (__is_convertible_helper<From, To, false>)
            (__is_nt_convertible_helper<From, To, false>, __nonesuch): Likewise.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272289 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libstdc++-v3/include/experimental/type_traits b/libstdc++-v3/include/experimental/type_traits
index 2403bd24223..464c8d2f4bf 100644
--- a/libstdc++-v3/include/experimental/type_traits
+++ b/libstdc++-v3/include/experimental/type_traits
@@ -227,6 +227,8 @@ inline namespace fundamentals_v2
 
 template<typename...> using void_t = void;
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
 struct __nonesuchbase {};
 struct nonesuch : private __nonesuchbase
 {
@@ -234,6 +236,7 @@ struct nonesuch : private __nonesuchbase
   nonesuch(nonesuch const&) = delete;
   void operator=(nonesuch const&) = delete;
 };
+#pragma GCC diagnostic pop
 
 template<template<typename...> class _Op, typename... _Args>
   using is_detected
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index e53d3c8d535..7d4deb156a1 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -1448,6 +1448,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef typename is_void<_To>::type type;
     };
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
   template<typename _From, typename _To>
     class __is_convertible_helper<_From, _To, false>
     {
@@ -1466,7 +1468,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     public:
       typedef decltype(__test<_From, _To>(0)) type;
     };
-
+#pragma GCC diagnostic pop
 
   /// is_convertible
   template<typename _From, typename _To>
@@ -1481,6 +1483,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : is_void<_To>
     { };
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
   template<typename _From, typename _To>
     class __is_nt_convertible_helper<_From, _To, false>
     {
@@ -1499,6 +1503,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     public:
       using type = decltype(__test<_From, _To>(0));
     };
+#pragma GCC diagnostic pop
 
   // is_nothrow_convertible for C++11
   template<typename _From, typename _To>
@@ -2894,12 +2899,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
              __call_is_nothrow_<_Fn, _Args...>>::type
     { };
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
   struct __nonesuchbase {};
   struct __nonesuch : private __nonesuchbase {
     ~__nonesuch() = delete;
     __nonesuch(__nonesuch const&) = delete;
     void operator=(__nonesuch const&) = delete;
   };
+#pragma GCC diagnostic pop
 
 #if __cplusplus >= 201703L
 # define __cpp_lib_is_invocable 201703

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

* Re: [PATCH] Disable -Wctor-dtor-privacy warnings for some standard types
  2019-06-14 14:05 [PATCH] Disable -Wctor-dtor-privacy warnings for some standard types Jonathan Wakely
@ 2019-06-15 10:53 ` Daniel Krügler
  2019-06-15 12:14   ` Daniel Krügler
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Krügler @ 2019-06-15 10:53 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches List

Am Fr., 14. Juni 2019 um 16:05 Uhr schrieb Jonathan Wakely <jwakely@redhat.com>:
>
> These types are not constructible by design, so we never want warnings
> for them, even with -Wsystem-headers.
>
>         * include/experimental/type_traits (experimental::nonesuch): Use
>         pragma to disable -Wctor-dtor-privacy warnings.
>         * include/std/type_traits (__is_convertible_helper<From, To, false>)
>         (__is_nt_convertible_helper<From, To, false>, __nonesuch): Likewise.
>
> Tested x86_64-linux, committed to trunk.

Unless I'm misunderstanding something, __nonesuchbase (twice) would
not be affected by that warning, so maybe the start of the
corresponding warning suppression could be moved after their
definition? Or did you do it that way to keep __nonesuchbase and
nonesuch close together?

- Daniel

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

* Re: [PATCH] Disable -Wctor-dtor-privacy warnings for some standard types
  2019-06-15 10:53 ` Daniel Krügler
@ 2019-06-15 12:14   ` Daniel Krügler
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Krügler @ 2019-06-15 12:14 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches List

Am Sa., 15. Juni 2019 um 12:52 Uhr schrieb Daniel Krügler
<daniel.kruegler@gmail.com>:
>
> Am Fr., 14. Juni 2019 um 16:05 Uhr schrieb Jonathan Wakely <jwakely@redhat.com>:
> >
> > These types are not constructible by design, so we never want warnings
> > for them, even with -Wsystem-headers.
> >
> >         * include/experimental/type_traits (experimental::nonesuch): Use
> >         pragma to disable -Wctor-dtor-privacy warnings.
> >         * include/std/type_traits (__is_convertible_helper<From, To, false>)
> >         (__is_nt_convertible_helper<From, To, false>, __nonesuch): Likewise.
> >
> > Tested x86_64-linux, committed to trunk.
>
> Unless I'm misunderstanding something, __nonesuchbase (twice) would
> not be affected by that warning, so maybe the start of the
> corresponding warning suppression could be moved after their
> definition? Or did you do it that way to keep __nonesuchbase and
> nonesuch close together?

Jonathan is momentarily not able to respond to this list using proper
email format, but he responded to me in private as follows:

"I did do that to keep them together, rather than introducing white
space between the base and the class using it. I even considered
putting the pragmas around the whole file, but decided to add them
just locally where needed.

I don't mind moving the base struct out of the pragma if you or
anybody else feels strongly, but thought it didn't do any harm this
way."

Personally I don't feel strongly about it - Thanks for the explanation!

- Daniel

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

end of thread, other threads:[~2019-06-15 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 14:05 [PATCH] Disable -Wctor-dtor-privacy warnings for some standard types Jonathan Wakely
2019-06-15 10:53 ` Daniel Krügler
2019-06-15 12:14   ` Daniel Krügler

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