From patchwork Fri Jul 29 08:04:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 298 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp678168pxt; Fri, 29 Jul 2022 01:06:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sMsmOt5Xj2fyNXj6UXVT9OWbaaJ2j0zFqU5xB3PUV5eMqzl5ExPnPVvksv3cPJAH9lejEv X-Received: by 2002:a17:907:b0a:b0:72b:3176:3fe5 with SMTP id h10-20020a1709070b0a00b0072b31763fe5mr2005349ejl.48.1659081981266; Fri, 29 Jul 2022 01:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659081981; cv=none; d=google.com; s=arc-20160816; b=n/lWR4EjLjLtNG+bWWfcLiKcvtEzPO/VSD303GvB3Z33otGyOtrhA9o36OkA8wOX+m M1PqLS6uiR7ssNU24JgPprqvNVsN01YbEw6R/LpcnXEADXbm6tAXxXn7u66fpBpGVfc3 iTjPgBWAZ1gHMZkxe/Rvn2HlbYJDSuzO/EmmocnfFOTHtzqT/BfaUuBE08XM+4Yyv4vB uXvgL84p9bV6Hvg4p1PvHZW1yn2+NLacnFlTlGUyJzOanHI6uIKJrt4PHI9IXIkb7gJM CZrkK104yUyI/6Pr8H4ipQpPZ7n5WVo0bcotxoH/f8aTBiyEKm5ZLZGwvFgpARkO4BB9 xULA== 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:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=iEGQPz5l5LztfjGZQT1Ipc1GVkncsil9GJKL/ghAI6I=; b=YNQCH5zUUOSsXEcb8JZNEAPG/eF6wxw5MqQGTRtwJYBctinnMZmG692hJ4dbI+K9Rf lok+T3SSPZZPVTSUxqLM+NmiGTf4ZOufMtVHSFAEH4pv78rrLp6QUGFBi7wEWjlXOdJ3 6CTE1u3dhum/3BKuNPvUM7c+8GrZEK6Rj/6oshpHzjCSSpBPxtA7iSt+nxV/GH2BjCfG Zpyu6p6moMi2jIk0Vzq4yfBe27NF0o+QSIKukbZE9vwIAA7n8WxHWZB5yDC6JQvnsLEL LSSok30FtQ5fcaae11UaregCJBiKK+yjkazQpLIbnJUhPJQwbxkJt6SBiwYegx2/cVb7 oP3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wdwsFMoY; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w20-20020a17090652d400b0072f67932939si2294277ejn.865.2022.07.29.01.06.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jul 2022 01:06:21 -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=wdwsFMoY; 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 760B03857348 for ; Fri, 29 Jul 2022 08:06:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 760B03857348 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659081963; bh=iEGQPz5l5LztfjGZQT1Ipc1GVkncsil9GJKL/ghAI6I=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=wdwsFMoYvbYyZ3iNA0nDTE+6pa2+/7R0mizFE3vTQGGJT7UNVLB2bqy6tl+1PLnYh ttfMzRXN4V9vLPvKYMMVK307wm7wv67zVp9eqHtxT5p/K1cTkF/qRch2zRk+tfXNuZ tF4YbE9UkRvML0fN95ZLihDxllsLGDCLqSA9sJJo= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 10F2A3857B87 for ; Fri, 29 Jul 2022 08:05:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 10F2A3857B87 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-142-K5ItFsjkMZywiic_5V2rHw-1; Fri, 29 Jul 2022 04:05:01 -0400 X-MC-Unique: K5ItFsjkMZywiic_5V2rHw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4E96A3801161; Fri, 29 Jul 2022 08:05:01 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 035EF1121314; Fri, 29 Jul 2022 08:05:00 +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 26T84wqN234423 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 10:04:58 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 26T84vRF234422; Fri, 29 Jul 2022 10:04:57 +0200 Date: Fri, 29 Jul 2022 10:04:57 +0200 To: gcc-patches@gcc.gnu.org Subject: [committed] openmp: Reject invalid forms of C++ #pragma omp atomic compare [PR106448] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP 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: Tobias Burnus 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?1739673547626636436?= X-GMAIL-MSGID: =?utf-8?q?1739673547626636436?= Hi! The allowed syntaxes of atomic compare don't allow ()s around the condition of ?:, but we were accepting it in one case for C++. Fixed thusly. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2022-07-29 Jakub Jelinek PR c++/106448 * parser.cc (cp_parser_omp_atomic): For simple cast followed by CPP_QUERY token, don't try cp_parser_binary_operation if compare is true. * c-c++-common/gomp/atomic-32.c: New test. Jakub --- gcc/cp/parser.cc.jj 2022-07-26 10:32:23.557273390 +0200 +++ gcc/cp/parser.cc 2022-07-28 15:12:44.288195066 +0200 @@ -41535,7 +41535,9 @@ restart: goto saw_error; } token = cp_lexer_peek_token (parser->lexer); - if (token->type != CPP_SEMICOLON && !cp_tree_equal (lhs, rhs1)) + if (token->type != CPP_SEMICOLON + && (!compare || token->type != CPP_QUERY) + && !cp_tree_equal (lhs, rhs1)) { cp_parser_abort_tentative_parse (parser); cp_parser_parse_tentatively (parser); --- gcc/testsuite/c-c++-common/gomp/atomic-32.c.jj 2022-07-28 15:23:54.567237524 +0200 +++ gcc/testsuite/c-c++-common/gomp/atomic-32.c 2022-07-28 15:25:25.127027325 +0200 @@ -0,0 +1,14 @@ +/* PR c++/106448 */ + +int x, expr; + +void +foo (void) +{ + #pragma omp atomic compare + x = (expr > x) ? expr : x; /* { dg-error "invalid (form|operator)" } */ + #pragma omp atomic compare + x = (x < expr) ? expr : x; /* { dg-error "invalid (form|operator)" } */ + #pragma omp atomic compare + x = (x == expr) ? expr : x; /* { dg-error "invalid (form|operator)" } */ +}