From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42057 invoked by alias); 30 Aug 2018 20:27:37 -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 42047 invoked by uid 89); 30 Aug 2018 20:27:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,KAM_SHORT,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f49.google.com Received: from mail-oi0-f49.google.com (HELO mail-oi0-f49.google.com) (209.85.218.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Aug 2018 20:27:35 +0000 Received: by mail-oi0-f49.google.com with SMTP id p84-v6so17826308oic.4 for ; Thu, 30 Aug 2018 13:27:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:5bcf:0:0:0:0:0 with HTTP; Thu, 30 Aug 2018 13:27:12 -0700 (PDT) In-Reply-To: <20180830153134.544d4bef@squid.athome> References: <20180830153134.544d4bef@squid.athome> From: Jason Merrill Date: Thu, 30 Aug 2018 20:27:00 -0000 Message-ID: Subject: Re: [PATCH, OpenACC] Support C++ "this" in OpenACC directives (PR66053) To: Julian Brown Cc: gcc-patches List , "Joseph S. Myers" , Jakub Jelinek Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg01995.txt.bz2 On Thu, Aug 30, 2018 at 3:31 PM, Julian Brown wrote: > This patch (by Joseph) allows "this" to be used in OpenACC directives, > following -- IIUC -- the behaviour of other compilers. The standard (as > of OpenACC 2.5) does not appear to have explicit language either > permitting or forbidding such usage. > > Joseph's original commentary is in the bug report (ca. 2015, > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66053): > > "This patch, for gomp-4_0-branch, adds support for C++ "this" in > OpenACC directives. (This patch does not do anything to handle OpenMP > differently from OpenACC; that - bug 66053 - will need to be resolved > for mainline, either deciding these cases should be accepted for > OpenMP or making the parsing only accept them in OpenACC directives > and not OpenMP ones.) > > "Apart from parsing, it's necessary to prevent the "cannot take the > address of 'this', which is an rvalue expression" error from appearing > when "this" is used in such contexts. This patch duly adds a new > argument to cxx_mark_addressable (default false so callers don't all > need to change) to allow disabling that error, passing that argument > in all calls that seem relevant to OpenACC directives." > > AFAICT though, this attached version of the patch does still forbid > "this" in OpenMP directives (apart from "declare simd"). I couldn't see > that there was any change to the OpenMP spec language in 4.5. > > Tested with offloading to NVPTX and bootstrapped. > > OK to apply? > > Julian > > ChangeLog > > 20xx-xx-xx Joseph Myers > > PR C++/66053 > > gcc/cp/ > * cp-tree.h (enum cxx_mark_addressable_flags): New. > (cxx_mark_addressable): Use it. Adjust users. > * parser.c (cp_parser_omp_var_list_no_open): Handle RID_THIS. > * semantics.c (handle_omp_array_sections_1) > (handle_omp_array_sections, finish_omp_reduction_clause) > (finish_omp_clauses): Pass CXX_MARK_ADDRESSABLE_FLAGS_ALLOW_THIS > to cxx_mark_addressable. Enforce "this" usage limitation only > for OpenMP. > * typeck.c (cp_build_array_ref): Adjust cxx_mark_addressble > call. (cxx_mark_addressable): Handle > CXX_MARK_ADDRESSABLE_FLAGS_ALLOW_THIS. > > libgomp/ > * testsuite/libgomp.oacc-c++/this.C: New test. Why does referring to this[0:1] require making 'this' addressable? Surely what we're interested in is the value of 'this', not the address. Jason