From patchwork Thu Oct 31 15:44:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 287516 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 84EC62C03BD for ; Fri, 1 Nov 2013 02:44:27 +1100 (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:subject:content-type; q= dns; s=default; b=YzZNNOtXDYV4xz3Gm3EOanoq8dM3HgIRT+PnaQzdY4Qe5d iR1cUR5CbxQ5a7Abse1Adf41cFkHaYd2ddp4sz6ikwgzVzUj27JcB/OrZ2SKcOuG afr9Ww0bXgPqzZL+dPV82XbgaqIuMjVpDAy2A0vfDoWk/Ie5aQLvVTpVa6ZBE= 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:subject:content-type; s= default; bh=VPLFYgV/fYmvh7mVQF9xA/SC62A=; b=FM3/hiPJA401Vy4otNGs PE3WYHeOifQ7LeUMxZilkUqGl0f+yfZMnLMv7Kiy2mi0yObWZSXNRD2V0zOEpaws NlYICJDNewYQY4/D7CM2nGgpHQvgsmX4fqqFv9eis6jFPsRlfqx0Ea/UHaU9L/3Z pY9w1k74mgmQzvznlF1NRNY= Received: (qmail 21452 invoked by alias); 31 Oct 2013 15:44:18 -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 21441 invoked by uid 89); 31 Oct 2013 15:44:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 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; Thu, 31 Oct 2013 15:44:16 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9VFiE2F024363 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 31 Oct 2013 11:44:15 -0400 Received: from [10.10.116.17] ([10.10.116.17]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9VFiE1o021844 for ; Thu, 31 Oct 2013 11:44:14 -0400 Message-ID: <52727ACD.40903@redhat.com> Date: Thu, 31 Oct 2013 11:44:13 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: gcc-patches List Subject: Two C++ cleanup PATCHes 1) Some changes to constant initialization that were needed by an early version of the "trivial but deleted" patch. They aren't needed anymore, but still seem correct. 2) We had two functions for building cleanup calls, which is unnecessary duplication. Also, there's no point in limiting use of LOOKUP_NONVIRTUAL in cxx_maybe_build_cleanup because it will be added anyway in build_new_method_call. Tested x86_64-pc-linux-gnu, applying to trunk. commit 72431a75a083a8e89cb44b0f2258b6400c98add6 Author: Jason Merrill Date: Thu Oct 17 14:05:37 2013 -0400 * decl.c (cxx_maybe_build_cleanup): Always set LOOKUP_NONVIRTUAL. * decl2.c (build_cleanup): Just call cxx_maybe_build_cleanup. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 476d559..09c1daa 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -14298,9 +14298,7 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain) type = TREE_TYPE (decl); if (type_build_dtor_call (type)) { - int flags = LOOKUP_NORMAL|LOOKUP_DESTRUCTOR; - bool has_vbases = (TREE_CODE (type) == RECORD_TYPE - && CLASSTYPE_VBASECLASSES (type)); + int flags = LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR; tree addr; tree call; @@ -14309,10 +14307,6 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain) else addr = build_address (decl); - /* Optimize for space over speed here. */ - if (!has_vbases || flag_expensive_optimizations) - flags |= LOOKUP_NONVIRTUAL; - call = build_delete (TREE_TYPE (addr), addr, sfk_complete_destructor, flags, 0, complain); if (call == error_mark_node) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index d776471..18e0e52 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2722,26 +2722,9 @@ import_export_decl (tree decl) tree build_cleanup (tree decl) { - tree temp; - tree type = TREE_TYPE (decl); - - /* This function should only be called for declarations that really - require cleanups. */ - gcc_assert (!TYPE_HAS_TRIVIAL_DESTRUCTOR (type)); - - /* Treat all objects with destructors as used; the destructor may do - something substantive. */ - mark_used (decl); - - if (TREE_CODE (type) == ARRAY_TYPE) - temp = decl; - else - temp = build_address (decl); - temp = build_delete (TREE_TYPE (temp), temp, - sfk_complete_destructor, - LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0, - tf_warning_or_error); - return temp; + tree clean = cxx_maybe_build_cleanup (decl, tf_warning_or_error); + gcc_assert (clean != NULL_TREE); + return clean; } /* Returns the initialization guard variable for the variable DECL,