From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62780 invoked by alias); 30 Mar 2018 14:42:12 -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 62771 invoked by uid 89); 30 Mar 2018 14:42:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f65.google.com Received: from mail-oi0-f65.google.com (HELO mail-oi0-f65.google.com) (209.85.218.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Mar 2018 14:42:10 +0000 Received: by mail-oi0-f65.google.com with SMTP id 188-v6so7959504oih.8 for ; Fri, 30 Mar 2018 07:42:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=eh8liC0FiTuuoqoKEDw6UkqsCHtgfhROgJXFje+/cf4=; b=FP2eoU2X/CkyLBANZ7AR7hOMN0wCaqisi3gMdb2O0YIOwzN4QH05W4gO1tNPRlMjc3 H+SgERYUsJgrtL+qvFGhsF4ll5WB/3W648C093DbIcST911b2meQfeZd7Fw6H1WDr6G3 CJgvkQBRBQThuahdfzBLjKM8HVtBQunNTvekVU4GiQX2jOp38X7wuuLfPslvugGIDf8C DrAuQm/voLDfcxkUHoh6QUULPVJlIdTQzhhrDVOwct++By/TA+Y1SyitmVf/NuOJ7Ptf tzPi9hWNpF5ylyhix+iNZnhIfSltwb3ozjkmuHrDDFTfkGNsL6Yf3tihHLQceDn1dtD1 oDkw== X-Gm-Message-State: AElRT7H9hKUn/8PdmsU+V/Etp2nCOO8DrSyWt3oHWsrbfxRgzfJdVch8 eSBULdCZkEFObG6hUhY7MQD9pccg5BjjVaxPUT37uQ== X-Google-Smtp-Source: AIpwx4+BKNk0K0tDlRybnSCjvP8cWwpBEpB/uJFdWJOYIELr5biljqqu+sJMxWnLOk3U18TIAeO1NacKFO21imYxZ78= X-Received: by 10.202.87.147 with SMTP id l141mr7385769oib.356.1522420928871; Fri, 30 Mar 2018 07:42:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.201.7.234 with HTTP; Fri, 30 Mar 2018 07:41:48 -0700 (PDT) In-Reply-To: References: From: Jason Merrill Date: Fri, 30 Mar 2018 14:46:00 -0000 Message-ID: Subject: Re: [PATCH] [PR c++/84943] allow folding of array indexing indirect_ref To: Alexandre Oliva Cc: gcc-patches List , Nathan Sidwell Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg01581.txt.bz2 On Fri, Mar 30, 2018 at 3:48 AM, Alexandre Oliva wrote: > On Mar 29, 2018, Alexandre Oliva wrote: > >> Here's a patch that should take care of the marking a namespace-scoped >> or static member function as used when taking its address, thus working >> around (fixing?) the reported problem. > >> Regstrapping now. Ok to install if it passes? > > It regressed overload/template1.C, because we mark an erroneous template > specialization as used when we attempt deduction. > > The following updated patch avoids that regression, and it has passed > bootstrap and regression testing on i686- and x86_64-linux-gnu. Ok to install? > > [PR c++/84943] mark function as used when taking its address > > fn[0]() ICEd because we would fold the INDIRECT_REF used for the > array indexing while building the address for the call, after not > finding the decl hiding there at first. But the decl would be exposed > by the folding, and then lower layers would complain we had the decl, > after all, but it wasn't one of the artificial or special functions > that could be called without being marked as used. > > This patch arranges for a FUNCTION_DECL to be marked as used when > taking its address, just like we already did when taking the address > of a static function to call it as a member function (i.e. using the > obj.fn() notation). However, we shouldn't mark functions as used when > just performing overload resolution, lest we might instantiate > templates we shouldn't, as in g++.dg/overload/template1.C. > > > for gcc/cp/ChangeLog > > PR c++/84943 > * typeck.c (cp_build_addr_expr_1): Mark FUNCTION_DECL as > used. > > for gcc/testsuite/ChangeLog > > PR c++/84943 > * g++.dg/pr84943.C: New. > * g++.dg/pr84943-2.C: New. > --- > gcc/cp/typeck.c | 9 +++++ > gcc/testsuite/g++.dg/pr84943-2.C | 64 ++++++++++++++++++++++++++++++++++++++ > gcc/testsuite/g++.dg/pr84943.C | 8 +++++ > 3 files changed, 80 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/pr84943-2.C > create mode 100644 gcc/testsuite/g++.dg/pr84943.C > > diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c > index d3183b5321d3..f6b25c8a837d 100644 > --- a/gcc/cp/typeck.c > +++ b/gcc/cp/typeck.c > @@ -5831,6 +5831,8 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain) > if (type_unknown_p (arg)) > return build1 (ADDR_EXPR, unknown_type_node, arg); > > + tree maybe_overloaded_arg = arg; I don't think we need this; if arg is overloaded, we take the type_unknown_p early exit, so the code lower down is always dealing with a single function. Jason