aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-12-01 09:11:56 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2017-12-01 09:11:56 +0100
commit9ede7b1bf0f85e3c14e09891ce0720c636ab8ffc (patch)
tree5a2552079fa390068f7264ee3b5120c89d9521de /gcc/tree-cfg.c
parent770cf505a1c1676f6d4c6968ddd05c5ea0f3af27 (diff)
downloadgcc-9ede7b1bf0f85e3c14e09891ce0720c636ab8ffc.zip
gcc-9ede7b1bf0f85e3c14e09891ce0720c636ab8ffc.tar.gz
gcc-9ede7b1bf0f85e3c14e09891ce0720c636ab8ffc.tar.bz2
re PR sanitizer/81275 (-fsanitize=thread produce incorrect -Wreturn-type warning)
PR sanitizer/81275 * tree-cfg.c (group_case_labels_stmt): Don't optimize away C++ FE implicitly added __builtin_unreachable () until -Wreturn-type is diagnosed. * c-c++-common/tsan/pr81275.c: Remove dg-skip-if. From-SVN: r255296
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 92f3201..4fb4a83 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1750,7 +1750,14 @@ group_case_labels_stmt (gswitch *stmt)
/* Discard cases that have an unreachable destination block. */
if (EDGE_COUNT (base_bb->succs) == 0
- && gimple_seq_unreachable_p (bb_seq (base_bb)))
+ && gimple_seq_unreachable_p (bb_seq (base_bb))
+ /* Don't optimize this if __builtin_unreachable () is the
+ implicitly added one by the C++ FE too early, before
+ -Wreturn-type can be diagnosed. We'll optimize it later
+ during switchconv pass or any other cfg cleanup. */
+ && (gimple_in_ssa_p (cfun)
+ || (LOCATION_LOCUS (gimple_location (last_stmt (base_bb)))
+ != BUILTINS_LOCATION)))
{
edge base_edge = find_edge (gimple_bb (stmt), base_bb);
if (base_edge != NULL)