From patchwork Wed Sep 7 07:04:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1004155wrt; Wed, 7 Sep 2022 00:05:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ftBc3dHP/2bTpEOo8Yg0uvU5EQfTMmjipdZvKXA8uVS4cA3tTAoK0yiBO1DmlAGox9qgn X-Received: by 2002:a17:907:e9e:b0:73e:933d:1c3d with SMTP id ho30-20020a1709070e9e00b0073e933d1c3dmr1341680ejc.622.1662534314565; Wed, 07 Sep 2022 00:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662534314; cv=none; d=google.com; s=arc-20160816; b=RzJ8GhlsBf/9sDCNfvUO3/aT0YHdCqecCIC7tSqgO9YMNfQBu1RL3glTOXLw7l2n+L 1oKb36QyBZVwXYItGLwj/xj9+KAyaBmcm6hLjstSK8tExtlzZXG/cO8ywHyWa13TVxlH t+2abSdEgGnRpBTp+TkByx5UNznmbl5WrQxIrLG3cTcSIkiQRXS2vom2sWqVQw9qY2Q6 Jw9HOJ7yhlyCxkFyrkgqtDHCpGSLy34RkxGNm+1uixV9BZZPiK/wIjqCnQ5x4QTGKpPm NfVhHkd/vWFwVB+tyTo7/gvsEXKKisHNV/ux9A3EHsbaO1WlvJ0daDNeJ7MbSeFu+Jgz 7Rpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:in-reply-to:mime-version:references:message-id :subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=hGfvMY6YCJSrUKm9VGTS9ZpmjMehSDDBuDc6uN9/rvs=; b=IPw/AagS9ZrLKdSVWWgNcnNyaHqtGZ1847XfP84+rJDiZmq/SRznEuSna8HBQNX0B0 4UjJ0F5yha7fDXB07Id7978htjYd3rPSRmiYvImACvU9hctRHU92jRvdiBecu1EgMM8Q y4tgeZgBrdPe3DezBpy5IpR5+Qyr/l80aJfI8xCG5F+Mx+A5YyM1ux30zs7hOLDYf+mY AN8Y5gR0sG5FMSsWP3PHL4NUy01D6+w2Zioey9y7NEwAAOaGgP9iGPUbl2QIWyCXKmd9 BqtT4/wvc4psG51Rk8gX/ChWstyJYuxICwHPXA47+ovxFFg95k3J/2cnB7J+OxwyQVtw WSuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oo8q7NuO; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i3-20020a1709064fc300b007306121368esi4328456ejw.668.2022.09.07.00.05.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 00:05:14 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oo8q7NuO; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 91AA738515D9 for ; Wed, 7 Sep 2022 07:05:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91AA738515D9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662534313; bh=hGfvMY6YCJSrUKm9VGTS9ZpmjMehSDDBuDc6uN9/rvs=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=oo8q7NuOuwAH/z1zY6BI+/Futg3SnKSQ30PVgJfk1LjLk7Mn/VHCtwa+9NnWqIT1y OfEFhN8/ccOQ6CyzEvoNZuIQqCPcYfqSH8UEIT7G4rXcGaL/HOiJY4S13d4Ze2H0XB cJ0sCWudK4a9ciIxddnnk7NkuQkt/o+MHZlluJ3A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 866783858D28 for ; Wed, 7 Sep 2022 07:04:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 866783858D28 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-277-exyMgR0XNR-Ksb11VaNI-g-1; Wed, 07 Sep 2022 03:04:26 -0400 X-MC-Unique: exyMgR0XNR-Ksb11VaNI-g-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB773811E87; Wed, 7 Sep 2022 07:04:25 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8894D492C3B; Wed, 7 Sep 2022 07:04:25 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 28774KDq3870454 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 7 Sep 2022 09:04:21 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 28774JfO3870453; Wed, 7 Sep 2022 09:04:19 +0200 Date: Wed, 7 Sep 2022 09:04:19 +0200 To: Chung-Lin Tang Subject: [committed] openmp: Fix handling of target constructs in static member functions [PR106829] Message-ID: References: <20210624131551.GR7746@tucnak> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743293581542721573?= X-GMAIL-MSGID: =?utf-8?q?1743293581542721573?= On Tue, Nov 16, 2021 at 08:43:27PM +0800, Chung-Lin Tang wrote: > 2021-11-16 Chung-Lin Tang > > PR middle-end/92120 > > gcc/cp/ChangeLog: > > * semantics.c (handle_omp_array_sections_1): Add handling to create ... > (finish_omp_target_clauses): New function. Just calling current_nonlambda_class_type in static member functions returns non-NULL, but something that isn't *this and if unlucky can match part of the IL and can be added to target clauses. if (DECL_NONSTATIC_MEMBER_P (decl) && current_class_ptr) is a guard used elsewhere (in check_accessibility_of_qualified_id). Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, queued for 12.3 backport. 2022-09-07 Jakub Jelinek PR c++/106829 * semantics.cc (finish_omp_target_clauses): If current_function_decl isn't a nonstatic member function, don't set data.current_object to non-NULL. * g++.dg/gomp/pr106829.C: New test. Jakub --- gcc/cp/semantics.cc.jj 2022-09-03 09:41:34.892005463 +0200 +++ gcc/cp/semantics.cc 2022-09-06 15:00:33.253199294 +0200 @@ -9555,16 +9555,15 @@ finish_omp_target_clauses (location_t lo { omp_target_walk_data data; data.this_expr_accessed = false; + data.current_object = NULL_TREE; - tree ct = current_nonlambda_class_type (); - if (ct) - { - tree object = maybe_dummy_object (ct, NULL); - object = maybe_resolve_dummy (object, true); - data.current_object = object; - } - else - data.current_object = NULL_TREE; + if (DECL_NONSTATIC_MEMBER_P (current_function_decl) && current_class_ptr) + if (tree ct = current_nonlambda_class_type ()) + { + tree object = maybe_dummy_object (ct, NULL); + object = maybe_resolve_dummy (object, true); + data.current_object = object; + } if (DECL_LAMBDA_FUNCTION_P (current_function_decl)) { --- gcc/testsuite/g++.dg/gomp/pr106829.C.jj 2022-09-06 15:03:44.305635408 +0200 +++ gcc/testsuite/g++.dg/gomp/pr106829.C 2022-09-06 15:03:12.987055704 +0200 @@ -0,0 +1,15 @@ +// PR c++/106829 + +namespace std +{ + template class complex; + template <> struct complex { complex (double); _Complex double d; }; +} +struct S { void static foo (); }; + +void +S::foo () +{ +#pragma omp target + std::complex c = 0.0; +}