diff options
author | Marek Polacek <polacek@redhat.com> | 2016-05-31 14:55:05 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2016-05-31 14:55:05 +0000 |
commit | 780b9dd44006c2f021dc1e2eb2509e0fa6005a6f (patch) | |
tree | 3f9f27e01869c122dc7dfd97c20e9ce1fe253901 /gcc/gimplify.c | |
parent | d7b03373d619b3ce715c760d2b21dbe4869a1c8f (diff) | |
download | gcc-780b9dd44006c2f021dc1e2eb2509e0fa6005a6f.zip gcc-780b9dd44006c2f021dc1e2eb2509e0fa6005a6f.tar.gz gcc-780b9dd44006c2f021dc1e2eb2509e0fa6005a6f.tar.bz2 |
gimplify.c (gimplify_switch_expr): Also handle GIMPLE_TRY.
* gimplify.c (gimplify_switch_expr): Also handle GIMPLE_TRY.
* c-c++-common/Wswitch-unreachable-3.c: New test.
* g++.dg/warn/Wswitch-unreachable-1.C: New test.
From-SVN: r236924
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 8316bb8..8b7dddc 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1609,10 +1609,17 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p) while (gimple_code (seq) == GIMPLE_BIND) seq = gimple_bind_body (as_a <gbind *> (seq)); gimple *stmt = gimple_seq_first_stmt (seq); - enum gimple_code code = gimple_code (stmt); - if (code != GIMPLE_LABEL && code != GIMPLE_TRY) + if (gimple_code (stmt) == GIMPLE_TRY) { - if (code == GIMPLE_GOTO + /* A compiler-generated cleanup or a user-written try block. + Try to get the first statement in its try-block, for better + location. */ + if ((seq = gimple_try_eval (stmt))) + stmt = gimple_seq_first_stmt (seq); + } + if (gimple_code (stmt) != GIMPLE_LABEL) + { + if (gimple_code (stmt) == GIMPLE_GOTO && TREE_CODE (gimple_goto_dest (stmt)) == LABEL_DECL && DECL_ARTIFICIAL (gimple_goto_dest (stmt))) /* Don't warn for compiler-generated gotos. These occur |