From patchwork Tue May 23 17:06:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 766113 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wXMPp5SjVz9sPD for ; Wed, 24 May 2017 03:06:36 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="yk/yVzNC"; dkim-atps=neutral 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=DNkcpv9zdp56Nsw0U+3UyzkW+grPgBIGr9byAxRpB8/3ZxglWI rZmWdbD++T/BglSH9MlY7Xvm4yDLG4iqxdeUN6p9cQFgZ/ikrYD/r3KTTD6A5F79 SJ1xRdM00OCQZzUscVEdT82m7rfFAkhrgHNX8u4ET64b1jA0D886VXThs= 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=uspHwZEymM4dR9KDbrqKBMcjTRI=; b=yk/yVzNCtbJZ8flFMBdC HrQXSSKxFWEJQobynzUYVpZd4X57b4eCIrmT2QvrOxV+aJ6UKREHRWz361TS9Nwz u9bDNddnqMUIM9voJ0fwFkcrFpQt/fRNqtLj8MvOz/CotBvZV6/evrl8jvOiKQNo 9AX4ZXwZ+aUwKc9HSNch0v0= Received: (qmail 12664 invoked by alias); 23 May 2017 17:06:23 -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 9976 invoked by uid 89); 23 May 2017 17:06:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=recycled X-HELO: mail-yw0-f178.google.com Received: from mail-yw0-f178.google.com (HELO mail-yw0-f178.google.com) (209.85.161.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 May 2017 17:06:16 +0000 Received: by mail-yw0-f178.google.com with SMTP id b68so77641151ywe.3 for ; Tue, 23 May 2017 10:06:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=mmaHm6oCmMQ10V+b1YDYJ/lfdZKSU4BW1ja3mv/loIs=; b=NJabgd6tFdKAp969gECHCF0WT6lOaWyDy9G+XJ8O+si/BY7sbsdfYdRrqMLljZLzB3 DcjvYpmlLkzpqGHIMgvBeK5ENTeCtvAfiqcxUfV/5PqoTiwT9YDqAH9m828Vz4IQ07Kc QEulAnyR6SEPYMr/YqJW8PFMqqeVDI4mIqo2uquZTe6Wd/LO2oP0mTfsTKGc6tGQoPoe N/4YcsS8ojstdcvQuU3OaO+bu/gg6rJh+c3yA2V0ds++iF54DSVsmRqRR5528AaG21xv U2F6s5jEH/ukU4Ezk2dV6mOGHbDLdFTtq6IgaOUcnd2d09LHEBJ0VTvgeRcLb7sMHkyv uUWw== X-Gm-Message-State: AODbwcANfcpNDFDtchU3PbisKlTVxEKp9nPr9quGGSjFJQsP1uEfn4Em 5OZ8PJcYNt7izA== X-Received: by 10.129.105.67 with SMTP id e64mr23233936ywc.129.1495559178695; Tue, 23 May 2017 10:06:18 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:f6d0:5ac5:64cd:f102? ([2620:10d:c091:200::94]) by smtp.googlemail.com with ESMTPSA id x203sm575514ywx.76.2017.05.23.10.06.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 May 2017 10:06:18 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] fix 80866 Message-ID: Date: Tue, 23 May 2017 13:06:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 This patch fixes 80866, a regression I introduced. The parser stashes template-ids when tentatively parsing, such ids can contain lookups. We need to mark the lookup as 'kept', otherwise the first parse could say 'I'm done with this' and recycle it prematurely. Applied to trunk. nathan 2017-05-23 Nathan Sidwell PR c++/80866 * parser.c (cp_parser_template_id): Keep the lookup when stashing the template_id. PR c++/80866 * g++.dg/parse/pr80866.C: New. Index: cp/parser.c =================================================================== --- cp/parser.c (revision 248372) +++ cp/parser.c (working copy) @@ -15570,6 +15570,11 @@ cp_parser_template_id (cp_parser *parser = make_location (token->location, token->location, finish_loc); token->location = combined_loc; + /* We must mark the lookup as kept, so we don't throw it away on + the first parse. */ + if (is_overloaded_fn (template_id)) + lookup_keep (get_fns (template_id), true); + /* Retrieve any deferred checks. Do not pop this access checks yet so the memory will not be reclaimed during token replacing below. */ token->u.tree_check_value = ggc_cleared_alloc (); Index: testsuite/g++.dg/parse/pr80866.C =================================================================== --- testsuite/g++.dg/parse/pr80866.C (revision 0) +++ testsuite/g++.dg/parse/pr80866.C (working copy) @@ -0,0 +1,10 @@ +// { dg-do compile { target c++11 } } +// PR 80866 recycled a lookup too soon. + +void pow(); +namespace math { + template void pow(T); +} +using namespace math; + +decltype(pow<>(0)) z();