From patchwork Thu May 14 14:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1290427 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=pPVVxkHc; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49NF1M3RQyz9sRK for ; Fri, 15 May 2020 00:54:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B4E0396D838; Thu, 14 May 2020 14:54:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by sourceware.org (Postfix) with ESMTPS id 26245395C05E for ; Thu, 14 May 2020 14:53:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 26245395C05E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qk1-x72c.google.com with SMTP id y22so3247020qki.3 for ; Thu, 14 May 2020 07:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:references:to:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=zXQ1SgacXGX80X0ZxmbEfc5iiqJ9U8yYtkHsDuiuQQk=; b=pPVVxkHcEZ9qfn7H9TbyEOR5GkAgCPYHl9jvMytExuJoAIByYLEJx/B+ZzJtLGjGfC a1Ur1gF/zhSzBhRua21fk2qdW9MQh6QKsAt80oEm7fM4s1tKMmkYqGAUiihz8Mffwvrq LNzoDjYo0hlv/mMtsHb5YbwrEv9ywJ5ba+o/HMa35YqTGQtTTrdNcnMz1Rx7QmLaprL4 7M0IE/T7zzZW4ICx5NCt4Ygc4B8Z9w6XLTkEX41nt2idKUsaekoynF9BQ1xDH0/OAnkj KI4A7NEmxEFirtsUSfhcdsooIBU/uAbGWCSQCdxQabPkn9Ga01Cb+s4IPZJcIS1hb5hh 3t6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:references:to:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=zXQ1SgacXGX80X0ZxmbEfc5iiqJ9U8yYtkHsDuiuQQk=; b=F5PsP0LIJJV4ke+DJNV/24RXhO8HxZW2m3GoxoOszuzbOTXQTAyBJjqqDRyIT4ccbw MjZr+E+bldir0c4CJbSl1vMvxCYuFicuAhV1Ik2t657zi9SnKSQYr+4YQMcwtV+nGGmB rUG7UGGY60tJnhgFT2sE0ezDc2R8RL8XYLot8VqYlbdWeophI7MdVaC5ICNGMAczYd0Y GfkzZ0ewSQr5VNdCOr0ZVVxH4GrcjMYzfY0lPnSZ5eMc2ZbBlcjKsJXyQu6hf2iy/FPw +yHpmv27KfRYp4uBBdVGg8wiyrUfooBJ7V8P8PO0anPFpNhhAj7E2b1M5zo66syfeWm1 iQZg== X-Gm-Message-State: AOAM532n3HZGc7fpIwkesVfg0RJ1022n6ddHLWlDaOmon2mS5gFgYlRt 9QIbugSoZt/7ULxZ/SzMJ3E= X-Google-Smtp-Source: ABdhPJyIN/cwy0lzJ9NN+C9XBU/D4imdN9/1+a+l6gIRAOrk5unApNsZqqHaf7gI+JVjjOuxgyZIiA== X-Received: by 2002:a05:620a:914:: with SMTP id v20mr5167410qkv.107.1589468037479; Thu, 14 May 2020 07:53:57 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a8:1102:fc0e:cf70:828a:a237? ([2620:10d:c091:480::1:158e]) by smtp.googlemail.com with ESMTPSA id c41sm2875127qta.96.2020.05.14.07.53.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 May 2020 07:53:56 -0700 (PDT) Subject: [C++] more pt.c simplifications References: To: GCC Patches From: Nathan Sidwell X-Forwarded-Message-Id: Message-ID: Date: Thu, 14 May 2020 10:53:55 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Pushed this bunch of simplifications to the template machinery. As ever, discovered when implementing modules and figuring out how it worked. inst-friend.diff tsubst_friend_function's control flow was a little complicated. This simplifies it, primarily by using more RAII. lkp-class.diff We were checking TYPE_NAME and then copying it if not null. Just copy it, and then see if we got null. push-tpl.diff Push_template_decl_real's friend-pushing logic was confusing me. This is more understandable. Fix a latent type bug I disovered. nathan 2020-05-14 Nathan Sidwell * pt.c (lookup_template_class_1): Remove unnecessary else by simply grabbing TYPE_NAME earlier. diff --git i/gcc/cp/pt.c w/gcc/cp/pt.c index 837644f8e6c..5ca659e9f28 100644 --- i/gcc/cp/pt.c +++ w/gcc/cp/pt.c @@ -9911,7 +9919,8 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, /* If we called start_enum or pushtag above, this information will already be set up. */ - if (!TYPE_NAME (t)) + type_decl = TYPE_NAME (t); + if (!type_decl) { TYPE_CONTEXT (t) = FROB_CONTEXT (context); @@ -9920,8 +9929,6 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, DECL_SOURCE_LOCATION (type_decl) = DECL_SOURCE_LOCATION (TYPE_STUB_DECL (template_type)); } - else - type_decl = TYPE_NAME (t); if (CLASS_TYPE_P (template_type)) {