diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-11-28 22:22:52 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-11-28 22:22:52 +0100 |
commit | 058f0b9e5f073da9d1d98a91e482cbdead1561ee (patch) | |
tree | 54a203fbcbecced881bb3fc81e309166d8c9ad5b /gcc/c | |
parent | 67c24a8bd6141021da49e005c0111bd42bfc7d08 (diff) | |
download | gcc-058f0b9e5f073da9d1d98a91e482cbdead1561ee.zip gcc-058f0b9e5f073da9d1d98a91e482cbdead1561ee.tar.gz gcc-058f0b9e5f073da9d1d98a91e482cbdead1561ee.tar.bz2 |
re PR sanitizer/81275 (-fsanitize=thread produce incorrect -Wreturn-type warning)
PR sanitizer/81275
* tree.c (block_may_fallthru): Return false if SWITCH_ALL_CASES_P
is set on SWITCH_EXPR and !block_may_fallthru (SWITCH_BODY ()).
c/
* c-typeck.c (c_finish_case): Set SWITCH_ALL_CASES_P if
c_switch_covers_all_cases_p returns true.
c-family/
* c-common.c (c_switch_covers_all_cases_p_1,
c_switch_covers_all_cases_p): New functions.
* c-common.h (c_switch_covers_all_cases_p): Declare.
testsuite/
* c-c++-common/tsan/pr81275.c: New test.
From-SVN: r255217
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index ff73043..2c36348 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2017-11-28 Jakub Jelinek <jakub@redhat.com> + + PR sanitizer/81275 + * c-typeck.c (c_finish_case): Set SWITCH_ALL_CASES_P if + c_switch_covers_all_cases_p returns true. + 2017-11-28 Julia Koval <julia.koval@intel.com> Sebastian Peryt <sebastian.peryt@intel.com> diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index f761305..6846bc5 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -10360,6 +10360,8 @@ c_finish_case (tree body, tree type) type ? type : TREE_TYPE (cs->switch_expr), SWITCH_COND (cs->switch_expr), cs->bool_cond_p, cs->outside_range_p); + if (c_switch_covers_all_cases_p (cs->cases, TREE_TYPE (cs->switch_expr))) + SWITCH_ALL_CASES_P (cs->switch_expr) = 1; /* Pop the stack. */ c_switch_stack = cs->next; |