From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26665 invoked by alias); 8 Jan 2019 04:08:19 -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 26652 invoked by uid 89); 8 Jan 2019 04:08:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=sk:noexcep, noticed, friend X-HELO: mail-qt1-f177.google.com Received: from mail-qt1-f177.google.com (HELO mail-qt1-f177.google.com) (209.85.160.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Jan 2019 04:08:17 +0000 Received: by mail-qt1-f177.google.com with SMTP id e5so2983851qtr.12 for ; Mon, 07 Jan 2019 20:08:17 -0800 (PST) Return-Path: Received: from [192.168.1.115] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id k16sm6139129qkj.38.2019.01.07.20.08.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 20:08:14 -0800 (PST) Subject: Re: C++ PATCH for c++/88548, this accepted in static member functions To: Marek Polacek , GCC Patches References: <20181222213830.GT21364@redhat.com> From: Jason Merrill Message-ID: <77923dac-487b-526e-804a-d1ac46b5d574@redhat.com> Date: Tue, 08 Jan 2019 04:08:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20181222213830.GT21364@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00366.txt.bz2 On 12/22/18 4:38 PM, Marek Polacek wrote: > I noticed that we weren't diagnosing using 'this' in noexcept-specifiers > of static member functions, and Jakub pointed out that this is also true > for trailing-return-type. cp_parser has local_variables_forbidden_p to > detect using local vars and 'this' in certain contexts, so let's use that. > > ...except that I found out that I need to be able to distinguish between > forbidding just local vars and/or this, so I've changed its type to char. > For instance, you can't use 'this' in a static member function declaration, > but you can use a local var because noexcept/decltype is an unevaluated > context. > > I also noticed that we weren't diagnosing 'this' in a friend declaration, > which is also forbidden. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? I wonder about suppressing inject_this_parm for a static member function, since current_class_ptr is unset within a static member function. But this approach (and patch) is also OK. Jason