From patchwork Tue Apr 7 12:34:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1267405 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=mvDatsLz; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xRgW1h38z9sSt for ; Tue, 7 Apr 2020 22:34:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D37C83887008; Tue, 7 Apr 2020 12:34:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D37C83887008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586262883; bh=wD/jT1ZvL0vJhI2nID4Oa3SiqNJfeFy2JEIm1uDTL1c=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mvDatsLz88X8xIV6bVnF/8yq0+0M8q7qONT0Fj7F/4oSFYA5qUJZ+F1j3hgPCuMVs QtcsVrYXDetymyyOkDz2m51s8voDlup+9uMYnU2I4a7l+MDqejGHkqIED024DXlSaC ekd2Bac+gqA3nLOUtELd4dT9rHtFNfG9G9neo0gA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id D6073385BF83 for ; Tue, 7 Apr 2020 12:34:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D6073385BF83 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-450-cCtTVIGRMaunwh9Yq5GncA-1; Tue, 07 Apr 2020 08:34:38 -0400 X-MC-Unique: cCtTVIGRMaunwh9Yq5GncA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A743801A0D for ; Tue, 7 Apr 2020 12:34:37 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3BBC10016DA for ; Tue, 7 Apr 2020 12:34:36 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 037CYYt7017965 for ; Tue, 7 Apr 2020 14:34:34 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 037CYXqq017964 for gcc-patches@gcc.gnu.org; Tue, 7 Apr 2020 14:34:33 +0200 Date: Tue, 7 Apr 2020 14:34:33 +0200 To: gcc-patches@gcc.gnu.org Subject: [committed] openmp: Fix parallel master error recovery [PR94512] Message-ID: <20200407123433.GC2212@tucnak> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-18.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: "Li, Pan2 via Gcc-patches" Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! We need to set OMP_PARALLEL_COMBINED only if the parsing of omp_master succeeded, because otherwise there is no nested master construct in the parallel. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, queued for backporting to 9.x. 2020-04-07 Jakub Jelinek PR c++/94512 * c-parser.c (c_parser_omp_parallel): Set OMP_PARALLEL_COMBINED if c_parser_omp_master succeeded. * parser.c (cp_parser_omp_parallel): Set OMP_PARALLEL_COMBINED if cp_parser_omp_master succeeded. * g++.dg/gomp/pr94512.C: New test. Jakub --- gcc/c/c-parser.c.jj 2020-03-23 19:44:48.271181302 +0100 +++ gcc/c/c-parser.c 2020-04-07 12:28:19.619763021 +0200 @@ -18877,9 +18877,9 @@ c_parser_omp_parallel (location_t loc, c stmt = c_finish_omp_parallel (loc, cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL], block); - OMP_PARALLEL_COMBINED (stmt) = 1; if (ret == NULL) return ret; + OMP_PARALLEL_COMBINED (stmt) = 1; return stmt; } else if (strcmp (p, "loop") == 0) --- gcc/cp/parser.c.jj 2020-04-04 09:14:29.911001109 +0200 +++ gcc/cp/parser.c 2020-04-07 12:27:21.977628266 +0200 @@ -39818,9 +39818,9 @@ cp_parser_omp_parallel (cp_parser *parse cp_parser_end_omp_structured_block (parser, save); stmt = finish_omp_parallel (cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL], block); - OMP_PARALLEL_COMBINED (stmt) = 1; if (ret == NULL_TREE) return ret; + OMP_PARALLEL_COMBINED (stmt) = 1; return stmt; } else if (strcmp (p, "loop") == 0) --- gcc/testsuite/g++.dg/gomp/pr94512.C.jj 2020-04-07 12:41:31.250883365 +0200 +++ gcc/testsuite/g++.dg/gomp/pr94512.C 2020-04-07 12:40:57.381391551 +0200 @@ -0,0 +1,18 @@ +// PR c++/94512 + +void +foo (); + +template +void +bar () +{ +#pragma omp parallel master taskloop + foo (); // { dg-error "for statement expected before" } +} + +void +baz () +{ + bar<0> (); +}