From patchwork Tue May 28 17:03:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1106408 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-501792-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.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 45D0YJ2W1qz9s5c for ; Wed, 29 May 2019 03:03:46 +1000 (AEST) 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=D+rYECU5Gl+OSmDq62x56GvdLA63SFsj9wdWMicmh/oD4geKrN vwKKSZGkE82surJzYkp8Ox46n1RXuyRFljMGmmJ5q+ubRlt/PvPjP06MXlypT/4T EfFB8k5iVQ6Od0UfsnJzxEFqIJiJKNosifJx8lyUPkU+Y/arqxsKp7Mlg= 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=G9Qw/mFRM51iNBr3wMNsbdlE8BY=; b=iuG92F8Qv3fD+60xiOuy i8rUgDKK20K0SNzDnwlp5tzQgefoZxxTDxkZPRpi6AoGxGpTyeT6Por6x/QPT6VW ujLs/X0zP3YG7a0r4EIMLq3UG30ov8KKYVX/JpYE7MsnXUj9Ey0YEfsflER8FBBs C0Cvb4ueLFzyswrh8b3Z8io= Received: (qmail 64341 invoked by alias); 28 May 2019 17:03:39 -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 64333 invoked by uid 89); 28 May 2019 17:03:39 -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=survived, 1998, HX-Google-DKIM-Signature:sender, surprise X-HELO: mail-pl1-f180.google.com Received: from mail-pl1-f180.google.com (HELO mail-pl1-f180.google.com) (209.85.214.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 May 2019 17:03:37 +0000 Received: by mail-pl1-f180.google.com with SMTP id p15so8602964pll.4 for ; Tue, 28 May 2019 10:03:37 -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=dRVRbLE3IzrHwV7kWezjxb/OyVhg3cKPkUe/3V36KEM=; b=udtNUjSRP39Amm4Ou6JXOSSGboog+msBg4QKJan3QTw9zVkBxpdi23Se2OsiJ6nLR1 SW+dXrcHANCfPOTvHvbemBKQmeQyoixrTyCRqzJJDvIavpUYFYbhICfJrq6douv8Zzbp MG4tn4D1FPup2mPSy6P3+TLFGb6TYKfIBWDOtPqpq6oTbjgoAsxcQgfAxBTtkVr3l2OE OpYNlBb7YOKW7y12SD6bhEP0NylIq8dZ56Pmw6Sosi/3BXFID8shC5Kv9mt3HL0bdK4S v43yxHUr+f2dXlnv1GTcIZiFlmuTTupuGPhK5iyzlYFD5C86KudDSvs/umXsrNknWwP6 mg3A== Received: from ?IPv6:2620:10d:c0a3:1407:cdb9:8e7f:490f:ed5c? ([2620:10d:c091:500::3:a7fa]) by smtp.googlemail.com with ESMTPSA id r2sm2147335pgb.62.2019.05.28.10.03.33 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 10:03:34 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] template specializations Message-ID: <23c6cd3c-51ed-f0d7-27a4-9092e6b84939@acm.org> Date: Tue, 28 May 2019 13:03:32 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In tracking a surprise on the modules branch, I came across this code in duplicate decls. Why would the newly minted decl already have specializations? That smells wrong. This chainon call was added by Mark Mitchell back in 1998, (rev 21876) to deal with template friends of templates. Since that time we've cleaned a lot of that code up, and in particular do not push the friend template until instantiation time. I believe these changes make this chainon unneeded. This patch changes it to assert there aren't any such specializations to concatenate. I'm putting this on trunk to give it wider exposure than I can on the modules branch. It has survived bootstrap on x86_64-linux. nathan 2019-05-28 Nathan Sidwell * decl.c (duplicate_decls): Assert a template newdecl has no specializations. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 271712) +++ cp/decl.c (working copy) @@ -2026,7 +2026,8 @@ duplicate_decls (tree newdecl, tree oldd tree new_result = DECL_TEMPLATE_RESULT (newdecl); TREE_TYPE (olddecl) = TREE_TYPE (old_result); - DECL_TEMPLATE_SPECIALIZATIONS (olddecl) - = chainon (DECL_TEMPLATE_SPECIALIZATIONS (olddecl), - DECL_TEMPLATE_SPECIALIZATIONS (newdecl)); + + /* The new decl should not already have gathered any + specializations. */ + gcc_assert (!DECL_TEMPLATE_SPECIALIZATIONS (newdecl)); DECL_ATTRIBUTES (old_result)