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 d093e203ffbd4cf12905ad3d5cd3bf2026ee4d22..d40073660b8686592d7f85c393fe55a5201015a6 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 96b2e45ae7a94c1751cfeb44439f1c090a9795e2..97206a122d215e3b9380473a5bb42083c69172f6 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 b2872082292282584eedb7e64b3db771e9b90802..ecfca8df524368346747cb92e92a6fb070415eb3 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);
+}