From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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 17:20:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F61C30DCABE65FDF5BE00AD8" X-SW-Source: 2017-05/txt/msg01789.txt.bz2 This is a multi-part message in MIME format. --------------F61C30DCABE65FDF5BE00AD8 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 313 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 -- Nathan Sidwell --------------F61C30DCABE65FDF5BE00AD8 Content-Type: text/x-patch; name="pr80866.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr80866.diff" Content-length: 1359 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(); --------------F61C30DCABE65FDF5BE00AD8--