From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76624 invoked by alias); 12 Feb 2018 22:49:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 76496 invoked by uid 89); 12 Feb 2018 22:49:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Feb 2018 22:49:28 +0000 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 mx1.redhat.com (Postfix) with ESMTPS id AB2DA7C6BB for ; Mon, 12 Feb 2018 22:49:21 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-85.brq.redhat.com [10.40.204.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 689FC100857A for ; Mon, 12 Feb 2018 22:49:21 +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 w1CMSF3X001324 for ; Mon, 12 Feb 2018 23:28:16 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w1CMSEIM001323 for gcc-patches@gcc.gnu.org; Mon, 12 Feb 2018 23:28:14 +0100 Date: Mon, 12 Feb 2018 22:49:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix OpenMP atomic and for condition C++ parsing (PR c++/84341) Message-ID: <20180212222814.GM5867@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00685.txt.bz2 Hi! In these cases, we want the tree to be just a placeholder for the operation plus 2 operands, we are going to take it appart later; by using build_min we can avoid the asserts build2_loc does, because the operands might not have the same type etc. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2018-02-12 Jakub Jelinek PR c++/84341 * parser.c (cp_parser_binary_expression): Use build_min instead of build2_loc to build the no_toplevel_fold_p toplevel binary expression. * c-c++-common/gomp/pr84341.c: New test. --- gcc/cp/parser.c.jj 2018-02-12 19:17:37.939216029 +0100 +++ gcc/cp/parser.c 2018-02-12 20:05:55.287322491 +0100 @@ -9330,12 +9330,14 @@ cp_parser_binary_expression (cp_parser* if (no_toplevel_fold_p && lookahead_prec <= current.prec && sp == stack) - current.lhs = build2_loc (combined_loc, - current.tree_type, - TREE_CODE_CLASS (current.tree_type) - == tcc_comparison - ? boolean_type_node : TREE_TYPE (current.lhs), - current.lhs, rhs); + { + current.lhs + = build_min (current.tree_type, + TREE_CODE_CLASS (current.tree_type) == tcc_comparison + ? boolean_type_node : TREE_TYPE (current.lhs), + current.lhs.get_value (), rhs.get_value ()); + SET_EXPR_LOCATION (current.lhs, combined_loc); + } else { current.lhs = build_x_binary_op (combined_loc, current.tree_type, --- gcc/testsuite/c-c++-common/gomp/pr84341.c.jj 2018-02-12 20:08:20.500327702 +0100 +++ gcc/testsuite/c-c++-common/gomp/pr84341.c 2018-02-12 20:08:00.290326972 +0100 @@ -0,0 +1,10 @@ +/* PR c++/84341 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +void +foo (int i) +{ + #pragma omp atomic + i = &i + 1; /* { dg-error "invalid form of" } */ +} Jakub