From: Jakub Jelinek Date: Tue, 25 Jun 2019 07:00:34 +0000 (+0200) Subject: re PR sanitizer/90954 (ICE: combining undefined behavior sanitizer with openmp) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=361af3e4194ce1d9620e2c3506115bba9ef18efa;p=gcc.git re PR sanitizer/90954 (ICE: combining undefined behavior sanitizer with openmp) 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 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d093e203ffb..d40073660b8 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2019-06-25 Jakub Jelinek + + 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 * c-common.c (braced_lists_to_strings): Check that diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 96b2e45ae7a..97206a122d2 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b2872082292..ecfca8df524 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-06-25 Jakub Jelinek + + PR sanitizer/90954 + * c-c++-common/gomp/pr90954.c: New test. + 2019-06-24 Iain Sandoe * 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 index 00000000000..cc3a6e9e52a --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr90954.c @@ -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); +}