From patchwork Wed Sep 17 15:37:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 390438 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 5DE9B140088 for ; Thu, 18 Sep 2014 01:37:54 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=AhsDA11Gq0ToCjY8kofWbkcVaqt6md48qPt1NP13JMg tiBZLmj5d62Kbhf9ubkRQyj6konsSSzgdrTXZgDSUbz9z15z/J6qhqLOnI2fJo/r AKzNzjwDjHaKsXkaHWST+qfeZx00X39w5w6Yt1+UN/cqiVXBAWqdAs2TZwYScGb8 = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=w11RihvKspqvoAgBrAJHK/krDqU=; b=HEkdzEfSrTh5gbGqG t8QjU6xl2NseeWCKsL6q/24dRSNbRmDQEx45L6d7le5pKKguOBKy4CXUbvJSwL2s O/iDfc8Ply9RvDYEFcKWne4g4X0lFRcL+2eklqrmyv04WJPaQxGsT6ZdAImI2Gkg ZGaH11NIncS5ty2qM4B80wpd1k= Received: (qmail 28281 invoked by alias); 17 Sep 2014 15:37:46 -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 28193 invoked by uid 89); 17 Sep 2014 15:37:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 17 Sep 2014 15:37:44 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s8HFbf5a017329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 17 Sep 2014 15:37:42 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s8HFbemh028512 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 17 Sep 2014 15:37:40 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s8HFbdMU010156; Wed, 17 Sep 2014 15:37:39 GMT Received: from [192.168.1.4] (/80.181.47.203) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Sep 2014 08:37:39 -0700 Message-ID: <5419AABF.3000006@oracle.com> Date: Wed, 17 Sep 2014 17:37:35 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 62232 X-IsSubscribed: yes Hi, clang recently, in 3.5.0 if I remember correctly, stopped -Wnon-virtual-dtor warning for final classes. I think it makes sense to do the same. Tested x86_64-linux. Thanks, Paolo. ////////////////////7 /cp 2014-09-17 Paolo Carlini PR c++/62232 * class.c (finish_struct_1): Do not -Wnon-virtual-dtor warn for final class types. /testsuite 2014-09-17 Paolo Carlini PR c++/62232 * g++.dg/cpp0x/Wdtor1.C: New. Index: cp/class.c =================================================================== --- cp/class.c (revision 215325) +++ cp/class.c (working copy) @@ -6506,7 +6506,8 @@ finish_struct_1 (tree t) /* This warning does not make sense for Java classes, since they cannot have destructors. */ if (!TYPE_FOR_JAVA (t) && warn_nonvdtor - && TYPE_POLYMORPHIC_P (t) && accessible_nvdtor_p (t)) + && TYPE_POLYMORPHIC_P (t) && accessible_nvdtor_p (t) + && !CLASSTYPE_FINAL (t)) warning (OPT_Wnon_virtual_dtor, "%q#T has virtual functions and accessible" " non-virtual destructor", t); Index: testsuite/g++.dg/cpp0x/Wdtor1.C =================================================================== --- testsuite/g++.dg/cpp0x/Wdtor1.C (revision 0) +++ testsuite/g++.dg/cpp0x/Wdtor1.C (working copy) @@ -0,0 +1,13 @@ +// PR c++/62232 +// { dg-do compile { target c++11 } } +// { dg-options "-Wnon-virtual-dtor" } + +class base +{ +protected: + ~base () {} + virtual void foo (){}; +}; +class derive final : public base +{ +};