From patchwork Tue Dec 5 17:27:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 844867 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-468539-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="y54tLWG5"; 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 3yrpbr1XXwz9t9S for ; Wed, 6 Dec 2017 04:27:52 +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=tGbHS3uFfQLRAMhbnuP/KocTHJ5YxZW0cJOBetzXEPxVgSr9kX YDu99PyRSb0hj1GxKpIvWiztT6MLIdh2TLZ/pjOfeKLnhV90m1LQhcU17oz+Pbb3 jqEl+jQWu+7b+jTzQtr9IyKY/IGkP+sUWHrEh/1R+BEI529w2+tE6Bohs= 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=7Qp0aU0Ixw2wFWFZp0oQzAx0bDI=; b=y54tLWG5ukf0zn7iyUyC fTpZ/B8URD+C4xCaAx0kOzDenjTrIOEyEWVbWKTUyD7iJc7zJWZcBKRew+RH/dwr 7vAMeiiXziEKy2twT9A6/tvRQZZ2oUYW3A6xsv2b44gpVBaQKPanoS6Lw1lWS23X wYIFv8/ndwk28ybF3nsFbuU= Received: (qmail 83151 invoked by alias); 5 Dec 2017 17:27:44 -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 83141 invoked by uid 89); 5 Dec 2017 17:27:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yw0-f174.google.com Received: from mail-yw0-f174.google.com (HELO mail-yw0-f174.google.com) (209.85.161.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Dec 2017 17:27:42 +0000 Received: by mail-yw0-f174.google.com with SMTP id g191so436984ywe.7 for ; Tue, 05 Dec 2017 09:27:42 -0800 (PST) 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=cuZm8bbg9d2A31AHHspF8PQBWbE186wtuPBjmTj58UA=; b=szlr14niDahli5/RPyigogUqlSNEO/oRP+TiO2mksJ8zCq+uX++NC77I6UJrZo+EkD wsfvstFqL11Qm1UBALlu4pMnFDS/ZKESNIQAbmBLDQJHfgwgICw1uYZSxIWqgcfFyRy+ eoov3vJw7cM/uZqDaeLOJA1hZuaLqv7mnui1+FgnTkKyMdtdHUlp+2EzmfeFNJ1hBfPX YVlBk3ig8rrqK7RWh4mYTE27VK1xxIWyiZc+6A4IT3tf4iGvvVcDIdgLFj8kxxXGFqnx ijyATTRNOyM1YIKtJkGRWQ0M35rCDSclVCtFZu0Lkfn3rDJ+KYRTCG9iFaLEhFI8Jg0D 12eA== X-Gm-Message-State: AJaThX5viq7Ifbw01MHcyJhi9hTTnU3pP1rkyL6pNX4+qlNMGnBQGe3H aSJKWKroOqY9NNlOGacu9daZaQ== X-Google-Smtp-Source: AGs4zMYcINyJwCncQQdjEW9/7ILCplfLMnNaBxzPhi4HoqW16rElPlk+e5NqE3dgqDFIq8kKMtX56Q== X-Received: by 10.129.87.210 with SMTP id l201mr13826755ywb.2.1512494861063; Tue, 05 Dec 2017 09:27:41 -0800 (PST) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::1:ed4c]) by smtp.googlemail.com with ESMTPSA id k2sm307436ywi.75.2017.12.05.09.27.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Dec 2017 09:27:40 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: [PR C++/83287] Mark lookup for keeping Message-ID: Date: Tue, 5 Dec 2017 12:27:38 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 This fixes 83287, a case where we failed to mark a lookup occuring inside a template definition as being kept for instantiation. It turns out that CAST_EXPR's single argument is a TREE_LIST, so we need to check it for OVERLOADS. CAST_EXPR behaves this way because it's modelling a function call. AFAICT it is the only node of this form. applying to trunk. nathan Index: cp/tree.c =================================================================== --- cp/tree.c (revision 255420) +++ cp/tree.c (working copy) @@ -3230,6 +3230,13 @@ build_min (enum tree_code code, tree tt, } va_end (p); + + if (code == CAST_EXPR) + /* The single operand is a TREE_LIST, which we have to check. */ + for (tree v = TREE_OPERAND (t, 0); v; v = TREE_CHAIN (v)) + if (TREE_CODE (TREE_VALUE (v)) == OVERLOAD) + lookup_keep (TREE_VALUE (v), true); + return t; } Index: testsuite/g++.dg/lookup/pr83287.C =================================================================== --- testsuite/g++.dg/lookup/pr83287.C (revision 0) +++ testsuite/g++.dg/lookup/pr83287.C (working copy) @@ -0,0 +1,19 @@ +// PR c++/83287 failed to keep lookup until instantiation time + +void foo (); + +namespace { + void foo (int); +} + +template +void bar () +{ + T (*p)() = (T (*)(void)) foo; +} + +void +baz () +{ + bar (); +}