From patchwork Tue Mar 15 18:20:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 87023 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]) by ozlabs.org (Postfix) with SMTP id 71D8FB72D7 for ; Wed, 16 Mar 2011 05:21:32 +1100 (EST) Received: (qmail 28531 invoked by alias); 15 Mar 2011 18:21:00 -0000 Received: (qmail 28507 invoked by uid 22791); 15 Mar 2011 18:20:48 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Mar 2011 18:20:28 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2FIKRHA015414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 15 Mar 2011 14:20:27 -0400 Received: from [127.0.0.1] (ovpn-113-56.phx2.redhat.com [10.3.113.56]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2FIKP2m009979 for ; Tue, 15 Mar 2011 14:20:26 -0400 Message-ID: <4D7FADE8.1040400@redhat.com> Date: Tue, 15 Mar 2011 14:20:24 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-patches List Subject: C++0x PATCH to implement core 1191 (deleted base destructor) 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 This patch implements the proposed resolution for core issue 1191: base destructors do not affect the triviality of derived constructors, but they do affect the exception specification and deletedness. Tested x86_64-pc-linux-gnu, applying to trunk. commit 15e4a01c978314724435064f20c373abf7a1bf8c Author: Jason Merrill Date: Sun Jan 23 17:52:44 2011 -0500 Core 1191 * method.c (synthezized_method_walk): Cleanups don't affect the triviality of a constructor, but do affect deletion and exception specification. diff --git a/gcc/cp/method.c b/gcc/cp/method.c index d70da95..0366988 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1080,14 +1080,9 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p, tsubst_flags_t complain; const char *msg; bool ctor_p; - tree cleanup_spec; - bool cleanup_trivial = true; - bool cleanup_deleted = false; - cleanup_spec - = (cxx_dialect >= cxx0x ? noexcept_true_spec : empty_except_spec); if (spec_p) - *spec_p = cleanup_spec; + *spec_p = (cxx_dialect >= cxx0x ? noexcept_true_spec : empty_except_spec); if (deleted_p) { @@ -1228,8 +1223,10 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p, destructors for cleanup of partially constructed objects. */ rval = locate_fn_flags (base_binfo, complete_dtor_identifier, NULL_TREE, flags, complain); - process_subob_fn (rval, false, &cleanup_spec, &cleanup_trivial, - &cleanup_deleted, NULL, NULL, + /* Note that we don't pass down trivial_p; the subobject + destructors don't affect triviality of the constructor. */ + process_subob_fn (rval, false, spec_p, NULL, + deleted_p, NULL, NULL, basetype); } @@ -1275,8 +1272,8 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p, { rval = locate_fn_flags (base_binfo, complete_dtor_identifier, NULL_TREE, flags, complain); - process_subob_fn (rval, false, &cleanup_spec, &cleanup_trivial, - &cleanup_deleted, NULL, NULL, + process_subob_fn (rval, false, spec_p, NULL, + deleted_p, NULL, NULL, basetype); } } @@ -1295,23 +1292,14 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p, if (ctor_p) walk_field_subobs (TYPE_FIELDS (ctype), complete_dtor_identifier, sfk_destructor, TYPE_UNQUALIFIED, false, - false, false, &cleanup_spec, &cleanup_trivial, - &cleanup_deleted, NULL, + false, false, spec_p, NULL, + deleted_p, NULL, NULL, flags, complain); pop_scope (scope); --cp_unevaluated_operand; --c_inhibit_evaluation_warnings; - - /* If the constructor isn't trivial, consider the subobject cleanups. */ - if (ctor_p && trivial_p && !*trivial_p) - { - if (deleted_p && cleanup_deleted) - *deleted_p = true; - if (spec_p) - *spec_p = merge_exception_specifiers (*spec_p, cleanup_spec); - } } /* DECL is a deleted function. If it's implicitly deleted, explain why and diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit11.C b/gcc/testsuite/g++.dg/cpp0x/implicit11.C new file mode 100644 index 0000000..7ec8e95 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit11.C @@ -0,0 +1,17 @@ +// Test that we consider base dtors in determining whether +// a derived ctor is deleted even if the ctor is trivial. +// { dg-options -std=c++0x } + +struct A +{ + ~A() = delete; // { dg-error "declared here" } +}; + +struct B: A { }; // { dg-error "deleted" } + +extern B eb; +int main() +{ + B* b1 = new B; // { dg-error "use of deleted function" "" { xfail *-*-* } } + B* b2 = new B(eb); // { dg-error "use of deleted function" } +}