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