]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/90884 - stray note with -Wctor-dtor-privacy.
authorMarek Polacek <polacek@redhat.com>
Thu, 15 Aug 2019 18:35:07 +0000 (18:35 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 15 Aug 2019 18:35:07 +0000 (18:35 +0000)
* class.c (maybe_warn_about_overly_private_class): Guard the call to
inform.

From-SVN: r274547

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.h [new file with mode: 0644]

index 6e9cb982478e6f461af814324fa16c45ed31b87e..f40ccc07f0bf1135aacedc8749d6a48722cf434d 100644 (file)
        * decl.c (check_default_argument): Don't return nullptr when the arg
        has side-effects.
 
+       2019-06-14  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/90884 - stray note with -Wctor-dtor-privacy.
+       * class.c (maybe_warn_about_overly_private_class): Guard the call to
+       inform.
+
 2019-08-14  Martin Sebor  <msebor@redhat.com>
 
        Backported from mainline
index a47777cdd9ef4d03d1652fa6e8c72b9b595b323f..b3b06eca3747891613967dabcd535000c6b82fb5 100644 (file)
@@ -2149,10 +2149,10 @@ maybe_warn_about_overly_private_class (tree t)
 
       if (!nonprivate_ctor)
        {
-         warning (OPT_Wctor_dtor_privacy,
-                  "%q#T only defines private constructors and has no friends",
-                  t);
-         if (copy_or_move)
+         bool w = warning (OPT_Wctor_dtor_privacy,
+                           "%q#T only defines private constructors and has "
+                           "no friends", t);
+         if (w && copy_or_move)
            inform (DECL_SOURCE_LOCATION (copy_or_move),
                    "%q#D is public, but requires an existing %q#T object",
                    copy_or_move, t);
diff --git a/gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.C b/gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.C
new file mode 100644 (file)
index 0000000..fcad34e
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/90884
+// { dg-options "-Wctor-dtor-privacy" }
+// { dg-prune-output "In file included from" }
+
+#include "ctor-dtor-privacy-4.h"  // { dg-bogus "is public" }
diff --git a/gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.h b/gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.h
new file mode 100644 (file)
index 0000000..d67fd26
--- /dev/null
@@ -0,0 +1,7 @@
+#pragma GCC system_header
+
+namespace std {
+struct __nonesuch {
+  __nonesuch(__nonesuch const &);
+};
+} // namespace std