diff mbox

[committed] Fix C #pragma omp atomic parsing (PR c/64824)

Message ID 20150211134303.GP1746@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Feb. 11, 2015, 1:43 p.m. UTC
Hi!

This patch fixes a thinko in POP macro in c_parser_binary_expression that
resulted in not triggering the build2 case if omp_atomic_lhs is non-NULL.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk so far, 4.9 testing in progress, 4.8 will follow at
some point.

2015-02-11  Jakub Jelinek  <jakub@redhat.com>

	PR c/64824
	* c-parser.c (c_parser_binary_expression): Fix OpenMP stack[sp].prec
	check in the POP macro.

	* testsuite/libgomp.c/atomic-18.c: New test.
	* testsuite/libgomp.c++/atomic-16.C: New test.


	Jakub
diff mbox

Patch

--- gcc/c/c-parser.c.jj	2015-02-04 23:30:34.000000000 +0100
+++ gcc/c/c-parser.c	2015-02-11 12:16:31.274379159 +0100
@@ -6233,8 +6233,8 @@  c_parser_binary_expression (c_parser *pa
     if (__builtin_expect (omp_atomic_lhs != NULL_TREE, 0) && sp == 1	      \
 	&& c_parser_peek_token (parser)->type == CPP_SEMICOLON		      \
 	&& ((1 << stack[sp].prec)					      \
-	    & (1 << (PREC_BITOR | PREC_BITXOR | PREC_BITAND | PREC_SHIFT      \
-		     | PREC_ADD | PREC_MULT)))				      \
+	    & ((1 << PREC_BITOR) | (1 << PREC_BITXOR) | (1 << PREC_BITAND)    \
+	       | (1 << PREC_SHIFT) | (1 << PREC_ADD) | (1 << PREC_MULT)))     \
 	&& stack[sp].op != TRUNC_MOD_EXPR				      \
 	&& stack[0].expr.value != error_mark_node			      \
 	&& stack[1].expr.value != error_mark_node			      \
--- libgomp/testsuite/libgomp.c/atomic-18.c.jj	2015-02-11 12:23:12.704648053 +0100
+++ libgomp/testsuite/libgomp.c/atomic-18.c	2015-02-11 12:24:11.749658560 +0100
@@ -0,0 +1,61 @@ 
+/* PR c/64824 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fopenmp" } */
+
+void
+f1 (void)
+{
+  short a;
+  short b = 1;
+  int c = 3;
+#pragma omp atomic capture
+  a = b = c << b;
+  if (b != 6 || a != 6)
+    __builtin_abort ();
+}
+
+void
+f2 (void)
+{
+  short a;
+  short b = 1;
+  int c = 3;
+#pragma omp atomic capture
+  a = b = c + b;
+  if (b != 4 || a != 4)
+    __builtin_abort ();
+}
+
+void
+f3 (void)
+{
+  short a;
+  short b = 1;
+  long long int c = 3;
+#pragma omp atomic capture
+  a = b = c + b;
+  if (b != 4 || a != 4)
+    __builtin_abort ();
+}
+
+void
+f4 (void)
+{
+  char a;
+  char b = 1;
+  long long int c = 3LL;
+#pragma omp atomic capture
+  a = b = c << b;
+  if (b != 6 || a != 6)
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  f1 ();
+  f2 ();
+  f3 ();
+  f4 ();
+  return 0;
+}
--- libgomp/testsuite/libgomp.c++/atomic-16.C.jj	2015-02-11 12:24:03.337799529 +0100
+++ libgomp/testsuite/libgomp.c++/atomic-16.C	2015-02-11 12:23:58.019888648 +0100
@@ -0,0 +1,5 @@ 
+// PR c/64824
+// { dg-do run }
+// { dg-options "-O2 -fopenmp" }
+
+#include "../libgomp.c/atomic-18.c"