From patchwork Wed Feb 8 14:08:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 725643 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 3vJNNP589cz9s7Z for ; Thu, 9 Feb 2017 01:08:37 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="EFXf5BRb"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=QSGXQsye8xVJx8WdjTkhSgO8/9UklV/oKWM0NsZ/sJmT5ZR/oc X598G/u28MxAIhwdu2wNXv/Q9xMknkCZANujITqBuzAk3HxuZJ6nKsNlqIhPmFj3 B8TR9o8xhyQ6riW9bkLlg1JfA6WU+mxNApYkKKGamQeM254HIUjQBcVcw= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=ptR0cp192hLX5ZNx/ChUpkWgYVM=; b=EFXf5BRbTXV7wNQ7ZVZo vrNq8fn97aWBghtLBfsahyX2fkMipYNU1SWgx7yTaLBS1ARTr1WyZhQpcbseA5B1 rtBfwcrtaYysUt5sQIVJWb7xrrupo4An45ofprQgj8hqzEJAgwoDyAuVuiYH5jds AZV2jpk7nd7XJfZ9RuaGCno= Received: (qmail 26000 invoked by alias); 8 Feb 2017 14:08:30 -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 25957 invoked by uid 89); 8 Feb 2017 14:08:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.1 required=5.0 tests=BAYES_50, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=throwing, cxx14, *constexpr_p, dtors X-HELO: mail-yw0-f196.google.com Received: from mail-yw0-f196.google.com (HELO mail-yw0-f196.google.com) (209.85.161.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Feb 2017 14:08:19 +0000 Received: by mail-yw0-f196.google.com with SMTP id l16so11928362ywb.2 for ; Wed, 08 Feb 2017 06:08:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:cc:from:subject:message-id:date :user-agent:mime-version; bh=btJ2f6dW76CRpsT5e+QLoN/AvmjuotyKCGYDmdxbWaM=; b=bxks7zUDeIJR85SvzL1rmkx+JW2hqwp64Gag7CKfKWH4fASqaKdrR1JMQCYtKht9eL raIatEIyPr3+TK2dN/Pi4AgyYZbOjMKYjkacVFqCej5vc5n/x0udkZoqJDLYcBOB+nUB wG2xg+c/WWV6G5tvRPgpexoErS9zATygFZA2KkJn8RU6zbXZK18BC8Wi1PT+p3DbN+15 /X/xjU/TqMR82237wvEvVTkmdOBnuJbgTAegAdfxgaZffkZXdMj4LCvty8mT/pO8tauH B0TbeyGRVoz08SsTehpQZ507WtQ9otaPLSNHSlJnyfnV2gLsmfFhcUhNTXrYVSr8dQED w1Vg== X-Gm-Message-State: AMke39ndQFluLbl7xbGnqyl8xKa3fhnoac04o1Ea6Gqp6LHIEQg42RxANnRNQvZNqMe4UA== X-Received: by 10.129.152.20 with SMTP id p20mr14369183ywg.281.1486562897574; Wed, 08 Feb 2017 06:08:17 -0800 (PST) Received: from ?IPv6:2620:10d:c0a3:20fb:f6d0:5ac5:64cd:f102? ([2620:10d:c091:200::4:3e50]) by smtp.googlemail.com with ESMTPSA id v207sm3857780ywa.6.2017.02.08.06.08.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Feb 2017 06:08:17 -0800 (PST) To: Jason Merrill Cc: Marek Polacek , GCC Patches From: Nathan Sidwell Subject: [C++PATCH] c++/79393 virtual base of abstract class Message-ID: Date: Wed, 8 Feb 2017 09:08:15 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 This patch fixes 79393, but I'm not 100% sure it's right. [15.4]/8 says: 'The exception specification for an implicitly-declared destructor, or a destructor without a noexcept-specifier, is potentially-throwing if and only if any of the destructors for any of its potentially constructed subojects is potentially throwing.' 'potentially constructed subobject' appears to be a term without definition. I have interpreted it to mean all the bases of the object, including virtual bases that are not deleted by a base destructor. This we add the eh specs for both virtual and non-virtual dtors of virtual bases. An alternative approach might be to just add eh specs of virtual dtors of virtual bases? While working on this I discovered 79424. In this testcase we synthesize A2::~A2's decl before we know A2 is abstract. By the time we need its eh-spec, we have worked that out though. Jason, wdyt? nathan 2017-02-08 Nathan Sidwell PR c++/79393 * method.c (synthesized_method_walk): Check vbases of abstract classes for eh spec. Index: cp/method.c =================================================================== --- cp/method.c (revision 245277) +++ cp/method.c (working copy) @@ -1660,12 +1660,21 @@ synthesized_method_walk (tree ctype, spe /* Already examined vbases above. */; else if (vec_safe_is_empty (vbases)) /* No virtual bases to worry about. */; - else if (ABSTRACT_CLASS_TYPE_P (ctype) && cxx_dialect >= cxx14) + else if (ABSTRACT_CLASS_TYPE_P (ctype) && cxx_dialect >= cxx14 + && !(sfk == sfk_destructor && spec_p)) /* Vbase cdtors are not relevant. */; else { if (constexpr_p) *constexpr_p = false; + + /* We might not be concerned with access, just the eh-spec for each + potentially-constructed sub-object. */ + bool no_access_check = (cxx_dialect >= cxx14 + && ABSTRACT_CLASS_TYPE_P (ctype)); + + if (no_access_check) + push_deferring_access_checks (dk_no_check); FOR_EACH_VEC_ELT (*vbases, i, base_binfo) synthesized_method_base_walk (binfo, base_binfo, quals, copy_arg_p, move_p, ctor_p, @@ -1673,6 +1682,8 @@ synthesized_method_walk (tree ctype, spe fnname, flags, diag, spec_p, trivial_p, deleted_p, constexpr_p); + if (no_access_check) + pop_deferring_access_checks (); } /* Now handle the non-static data members. */ Index: testsuite/g++.dg/cpp1y/pr79393.C =================================================================== --- testsuite/g++.dg/cpp1y/pr79393.C (revision 0) +++ testsuite/g++.dg/cpp1y/pr79393.C (working copy) @@ -0,0 +1,21 @@ +// { dg-do compile { target c++14 } } +// PR c++/79393 deduced eh spec, deleted dtors and vbases + +struct A3; + +struct VDT { + virtual ~VDT () noexcept (false); +}; + +struct A1 : virtual VDT { + virtual void abstract () = 0; +}; + +struct A2 : A1 { }; + +struct A3 : A2 +{ + virtual void abstract (); +}; + +A3 a3;