re PR sanitizer/90954 (ICE: combining undefined behavior sanitizer with openmp)
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 Jun 2019 07:00:34 +0000 (09:00 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 25 Jun 2019 07:00:34 +0000 (09:00 +0200)
PR sanitizer/90954
* c-omp.c (c_finish_omp_atomic): Allow tree_invariant_p in addition
to SAVE_EXPR in first operand of a COMPOUND_EXPR.

* c-c++-common/gomp/pr90954.c: New test.

From-SVN: r272635

gcc/c-family/ChangeLog
gcc/c-family/c-omp.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/pr90954.c [new file with mode: 0644]

index d093e20..d400736 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/90954
+       * c-omp.c (c_finish_omp_atomic): Allow tree_invariant_p in addition
+       to SAVE_EXPR in first operand of a COMPOUND_EXPR.
+
 2019-06-24  Jan Hubicka  <jh@suse.cz>
 
        * c-common.c (braced_lists_to_strings): Check that
index 96b2e45..97206a1 100644 (file)
@@ -305,7 +305,7 @@ c_finish_omp_atomic (location_t loc, enum tree_code code,
   if (TREE_CODE (x) == COMPOUND_EXPR)
     {
       pre = TREE_OPERAND (x, 0);
-      gcc_assert (TREE_CODE (pre) == SAVE_EXPR);
+      gcc_assert (TREE_CODE (pre) == SAVE_EXPR || tree_invariant_p (pre));
       x = TREE_OPERAND (x, 1);
     }
   gcc_assert (TREE_CODE (x) == MODIFY_EXPR);
index b287208..ecfca8d 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/90954
+       * c-c++-common/gomp/pr90954.c: New test.
+
 2019-06-24  Iain Sandoe  <iain@sandoe.co.uk>
 
        * gcc.target/powerpc/safe-indirect-jump-1.c: Skip for Darwin.
diff --git a/gcc/testsuite/c-c++-common/gomp/pr90954.c b/gcc/testsuite/c-c++-common/gomp/pr90954.c
new file mode 100644 (file)
index 0000000..cc3a6e9
--- /dev/null
@@ -0,0 +1,27 @@
+/* PR sanitizer/90954 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -fsanitize=undefined" } */
+
+float v;
+int i;
+
+void
+foo (float x, float y)
+{
+  #pragma omp atomic
+  v += x / y;
+}
+
+void
+bar (int x, int y)
+{
+  #pragma omp atomic
+  i += x / y;
+}
+
+void
+baz (int x, int y)
+{
+  #pragma omp atomic
+  i *= (x << y);
+}