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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 349453858435 for ; Wed, 29 Sep 2021 08:29:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 349453858435 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-1wDJQG2IOZ-EikRdsIgfEw-1; Wed, 29 Sep 2021 04:29:01 -0400 X-MC-Unique: 1wDJQG2IOZ-EikRdsIgfEw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9103A362FF; Wed, 29 Sep 2021 08:29:00 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.109]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D67A15BAE3; Wed, 29 Sep 2021 08:28:59 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 18T8SuWp356671 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 29 Sep 2021 10:28:57 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 18T8SuYv356670; Wed, 29 Sep 2021 10:28:56 +0200 Date: Wed, 29 Sep 2021 10:28:55 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: Tobias Burnus Subject: [committed] openmp: Disallow reduction with var private in containing parallel even on scope [PR102504] Message-ID: <20210929082855.GK304296@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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=-5.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Wed, 29 Sep 2021 08:29:04 -0000 Hi! The standard has a restriction: "A list item that appears in a reduction clause of a scope construct must be shared in the parallel region to which a corresponding scope region binds." similar to the restriction for worksharing constructs, but we were checking it only on worksharing constructs and not for scope and ICEd later on during omp expansion. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2021-09-29 Jakub Jelinek PR middle-end/102504 * gimplify.c (gimplify_scan_omp_clauses): Use omp_check_private even in OMP_SCOPE clauses, not just on worksharing construct clauses. * c-c++-common/gomp/scope-4.c: New test. --- gcc/gimplify.c.jj 2021-09-28 11:37:55.905290494 +0200 +++ gcc/gimplify.c 2021-09-28 13:39:30.563366270 +0200 @@ -10195,7 +10195,7 @@ gimplify_scan_omp_clauses (tree *list_p, if (outer_ctx) omp_notice_variable (outer_ctx, decl, true); if (check_non_private - && region_type == ORT_WORKSHARE + && (region_type == ORT_WORKSHARE || code == OMP_SCOPE) && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION || decl == OMP_CLAUSE_DECL (c) || (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF --- gcc/testsuite/c-c++-common/gomp/scope-4.c.jj 2021-09-28 13:45:32.694358993 +0200 +++ gcc/testsuite/c-c++-common/gomp/scope-4.c 2021-09-28 13:46:54.775224041 +0200 @@ -0,0 +1,11 @@ +/* PR middle-end/102504 */ +/* { dg-do compile } */ + +int +foo () +{ + int r = 0; + #pragma omp scope reduction(+:r) /* { dg-error "reduction variable 'r' is private in outer context" } */ + r++; + return r; +} Jakub