public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [committed] Fix OpenMP atomic and for condition C++ parsing (PR c++/84341)
Date: Mon, 12 Feb 2018 22:49:00 -0000	[thread overview]
Message-ID: <20180212222814.GM5867@tucnak> (raw)

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  <jakub@redhat.com>

	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

                 reply	other threads:[~2018-02-12 22:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180212222814.GM5867@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).