From 361af3e4194ce1d9620e2c3506115bba9ef18efa Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 25 Jun 2019 09:00:34 +0200 Subject: [PATCH] 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 --- gcc/c-family/ChangeLog | 6 ++++++ gcc/c-family/c-omp.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/gomp/pr90954.c | 27 +++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/c-c++-common/gomp/pr90954.c diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d093e20..d400736 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 96b2e45..97206a1 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 b287208..ecfca8d 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 0000000..cc3a6e9 --- /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); +} -- 2.7.4