From patchwork Tue Oct 15 11:19:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1176937 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-510999-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uWNRBNy9"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KnF/p2ls"; dkim-atps=neutral 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 46stHJ6qvxz9sPZ for ; Tue, 15 Oct 2019 22:19:24 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=J/exKBytkQC/usXgBrbwlciixw2MXQpwEc+M7/8HCL8gy8+buw Wc64XhXrAt8EWRSd8uyAp88Xq1Ak39Izf9uM5RQ6mCaYCMuV7m+2Xsx1v1P7jSwW UG7VhpSQzZZkEUxzfRJ0U/D1O/XroRRH2QIHQkzIiOxDy66yDErYjiJHw= 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 :from:subject:message-id:date:mime-version:content-type; s= default; bh=1bIWoUHIzO7Btl9Lzurno7PPLJQ=; b=uWNRBNy9cBvFjGnMzkgq 8hsAvwkmDpvWpEGZaJ5gAXb1+0KmnPBRVJd1qwPe0z9XLI5Xz/2JSPVF5sTlylBc WGxB6VcaWu2DtOXlTigcdoyv4u78WcNezB0HfCeCwCoCFMfXfUCvIvet0NfWQef8 1xiB1BadHA07A18e9H8dN3s= Received: (qmail 70228 invoked by alias); 15 Oct 2019 11:19:17 -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 70218 invoked by uid 89); 15 Oct 2019 11:19:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Received:1469, parms X-HELO: mail-qk1-f171.google.com Received: from mail-qk1-f171.google.com (HELO mail-qk1-f171.google.com) (209.85.222.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Oct 2019 11:19:16 +0000 Received: by mail-qk1-f171.google.com with SMTP id w2so18784055qkf.2 for ; Tue, 15 Oct 2019 04:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=GtVRmdKNfUhkqndR9lM5VkijHlzM6nbC52YvYlQKWPY=; b=KnF/p2lsowgJ4d1TjRdl3Wn+1L1OmgorS2SBeMFLlqwIHnejuJPRqoFAa0UGPqnSIR KkZ11UVIwRe9T2jSfUZGZFIEjw1Zt3KhNBhThhLmlsJ18xcBnb331jVLc7IBBYi3HktR 3RR59ncxl0DwMvqFYy0Yg5Lxudvwooc5x8RUn5zzW6u52D34JTyDcIpiLxTcEG+PwhpF 7c4mnLI9q3tnlgvnwPfrckd4n8s09/hyYOF79QwFnXZw4mwvBHuExqkVH313O/zzNtpQ UFrUGXNA/eEDomw840hL8a2z9XERS/StYtl95mcRPGjADka0KyM39Um25AQe8JOCDx4M sGmQ== Received: from ?IPv6:2620:10d:c0a3:1407:f888:8672:b7f1:b6cf? ([2620:10d:c091:500::1:ca40]) by smtp.googlemail.com with ESMTPSA id e42sm14343086qte.26.2019.10.15.04.19.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Oct 2019 04:19:13 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] build_clone cleanup Message-ID: <13b39e29-91e6-c679-8580-9a3c6c05f64f@acm.org> Date: Tue, 15 Oct 2019 07:19:11 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 build_clone is recursive when applied to a template, but I found the control flow confusing. this makes it clearer and moves some decls to their initializers. Applying to trunk. nathan 2019-10-15 Nathan Sidwell * class.c (build_clone): Refactor to clarify recursiveness. Index: gcc/cp/class.c =================================================================== --- gcc/cp/class.c (revision 276991) +++ gcc/cp/class.c (working copy) @@ -4582,14 +4582,13 @@ static tree build_clone (tree fn, tree name) { - tree parms; - tree clone; - /* Copy the function. */ - clone = copy_decl (fn); + tree clone = copy_decl (fn); /* Reset the function name. */ DECL_NAME (clone) = name; /* Remember where this function came from. */ DECL_ABSTRACT_ORIGIN (clone) = fn; - /* Make it easy to find the CLONE given the FN. */ + + /* Make it easy to find the CLONE given the FN. Note the + template_result of a template will be chained this way too. */ DECL_CHAIN (clone) = DECL_CHAIN (fn); DECL_CHAIN (fn) = clone; @@ -4600,17 +4599,16 @@ build_clone (tree fn, tree name) tree result = build_clone (DECL_TEMPLATE_RESULT (clone), name); DECL_TEMPLATE_RESULT (clone) = result; + DECL_TEMPLATE_INFO (result) = copy_node (DECL_TEMPLATE_INFO (result)); DECL_TI_TEMPLATE (result) = clone; + TREE_TYPE (clone) = TREE_TYPE (result); return clone; } - else - { - /* Clone constraints. */ - if (flag_concepts) - if (tree ci = get_constraints (fn)) - set_constraints (clone, copy_node (ci)); - } + if (flag_concepts) + /* Clone constraints. */ + if (tree ci = get_constraints (fn)) + set_constraints (clone, copy_node (ci)); SET_DECL_ASSEMBLER_NAME (clone, NULL_TREE); @@ -4624,6 +4622,5 @@ build_clone (tree fn, tree name) { DECL_VIRTUAL_P (clone) = 0; - if (TREE_CODE (clone) != TEMPLATE_DECL) - DECL_VINDEX (clone) = NULL_TREE; + DECL_VINDEX (clone) = NULL_TREE; } @@ -4690,5 +4687,5 @@ build_clone (tree fn, tree name) DECL_CHAIN (DECL_CHAIN (DECL_ARGUMENTS (clone))) = NULL_TREE; - for (parms = DECL_ARGUMENTS (clone); parms; parms = DECL_CHAIN (parms)) + for (tree parms = DECL_ARGUMENTS (clone); parms; parms = DECL_CHAIN (parms)) { DECL_CONTEXT (parms) = clone;