From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662534269; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=hGfvMY6YCJSrUKm9VGTS9ZpmjMehSDDBuDc6uN9/rvs=; b=cLvKqrQR6gEVP32rafukX/xkXrLUS3bCtJ0kNBsONPmaqJHTXQeh3LpeNnRVGdNmULk4SU /tp0SlFMuhUBU1e2FnaSVn/Zpy+2u7cEcXZZ5Nane3SELWMPL6tqrrU9pCVaadM2+D20Us YvI4TjlgXlrSQNhR6Xj+LX33yiyH3r8= 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 From: Jakub Jelinek To: Chung-Lin Tang Cc: gcc-patches Subject: [committed] openmp: Fix handling of target constructs in static member functions [PR106829] Message-ID: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=us-ascii 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 List-Id: 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. --- 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; +} Jakub