From patchwork Fri Jun 14 12:10:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1115941 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-502961-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45QKFY4Sfbz9s7h for ; Fri, 14 Jun 2019 22:10:48 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=sWmP1/+DxMqrXEC5ohueJN4TlI5erbabNcssPkCU9/VVfncDTZNuG 4y0r7l6Mhd8DKLnAhSdzUD+96e6eQlR83p88BWVDueX+/xBNhcJwdDvcOpCYdreu qum9kQq8ylT7F/AHy/FOxY6qitbgrJviiMAy1KbSy5h6yopReh/2vQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=WnbdR/gVBUa00WYufmcSLQmAUPA=; b=Vakd7PVq6EJrkSMiGDIp U2wKUDIHTG7YEx6d8XhQbxLKGKZVYOiUi62mtb9TWX/vonJY1lYxXt0owiBBBhtz L6l+0SvNySeNva0M5zrijckrT2O6YWLk38fv1GkRex+0QJC6GWRwhWO5t7Pcjamr yVw7y5+whus3HsH50cFxQYs= Received: (qmail 103524 invoked by alias); 14 Jun 2019 12:10:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 101889 invoked by uid 89); 14 Jun 2019 12:10:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=sk:DECL_SO, sk:decl_so X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Jun 2019 12:10:37 +0000 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96CF630C0DDC for ; Fri, 14 Jun 2019 12:10:36 +0000 (UTC) Received: from redhat.com (ovpn-120-65.rdu2.redhat.com [10.10.120.65]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED5E02854C; Fri, 14 Jun 2019 12:10:35 +0000 (UTC) Date: Fri, 14 Jun 2019 08:10:33 -0400 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH for c++/90884 - stray note with -Wctor-dtor-privacy Message-ID: <20190614121033.GF5989@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.4 (2019-03-13) This patch fixes a naked inform call, resulting in bogus note in the following testcase, if not compiled with -Wsystem-headers. Bootstrap/regtest running on x86_64-linux, ok for trunk? 2019-06-14 Marek Polacek PR c++/90884 - stray note with -Wctor-dtor-privacy. * class.c (maybe_warn_about_overly_private_class): Guard the call to inform. * g++.dg/warn/ctor-dtor-privacy-4.C: New. * g++.dg/warn/ctor-dtor-privacy-4.h: New. diff --git gcc/cp/class.c gcc/cp/class.c index 4fdb0f328cc..de37e43d04c 100644 --- gcc/cp/class.c +++ gcc/cp/class.c @@ -2150,10 +2150,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 gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.C gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.C new file mode 100644 index 00000000000..fcad34e000c --- /dev/null +++ gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.C @@ -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 gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.h gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.h new file mode 100644 index 00000000000..d67fd26943e --- /dev/null +++ gcc/testsuite/g++.dg/warn/ctor-dtor-privacy-4.h @@ -0,0 +1,7 @@ +#pragma GCC system_header + +namespace std { +struct __nonesuch { + __nonesuch(__nonesuch const &); +}; +} // namespace std