From 295844f68760cd2c8d38e5cd42ba0f81b55cb65b Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 1 Sep 2016 14:59:50 +0000 Subject: [PATCH] re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) PR c/7652 gcc/c-family/ * c-common.c (resolve_overloaded_builtin): Fix formatting. Add FALLTHRU comments. gcc/c/ * c-typeck.c (composite_type): Add FALLTHRU comment. gcc/gcc/cp/ * error.c (dump_type): Fix falls through comment. (dump_decl): Likewise. (dump_expr): Likewise. From-SVN: r239939 --- gcc/c-family/ChangeLog | 6 ++++++ gcc/c-family/c-common.c | 18 +++++++----------- gcc/c/ChangeLog | 5 +++++ gcc/c/c-typeck.c | 2 +- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/error.c | 6 +++--- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 2a38deb1666..8a40f75da4f 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2016-09-01 Marek Polacek + + PR c/7652 + * c-common.c (resolve_overloaded_builtin): Fix formatting. Add + FALLTHRU comments. + 2016-08-29 Marek Polacek PR c/77292 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index b29334ad9af..399ba975184 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -11547,7 +11547,7 @@ resolve_overloaded_builtin (location_t loc, tree function, /* Handle these 4 together so that they can fall through to the next case if the call is transformed to an _N variant. */ switch (orig_code) - { + { case BUILT_IN_ATOMIC_EXCHANGE: { if (resolve_overloaded_atomic_exchange (loc, function, params, @@ -11588,17 +11588,15 @@ resolve_overloaded_builtin (location_t loc, tree function, } default: gcc_unreachable (); - } - /* Fallthrough to the normal processing. */ + } } + /* FALLTHRU */ case BUILT_IN_ATOMIC_EXCHANGE_N: case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_N: case BUILT_IN_ATOMIC_LOAD_N: case BUILT_IN_ATOMIC_STORE_N: - { - fetch_op = false; - /* Fallthrough to further processing. */ - } + fetch_op = false; + /* FALLTHRU */ case BUILT_IN_ATOMIC_ADD_FETCH_N: case BUILT_IN_ATOMIC_SUB_FETCH_N: case BUILT_IN_ATOMIC_AND_FETCH_N: @@ -11611,10 +11609,8 @@ resolve_overloaded_builtin (location_t loc, tree function, case BUILT_IN_ATOMIC_FETCH_NAND_N: case BUILT_IN_ATOMIC_FETCH_XOR_N: case BUILT_IN_ATOMIC_FETCH_OR_N: - { - orig_format = false; - /* Fallthru for parameter processing. */ - } + orig_format = false; + /* FALLTHRU */ case BUILT_IN_SYNC_FETCH_AND_ADD_N: case BUILT_IN_SYNC_FETCH_AND_SUB_N: case BUILT_IN_SYNC_FETCH_AND_OR_N: diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3ac6648b45a..6b00f9a5f1e 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2016-09-01 Marek Polacek + + PR c/7652 + * c-typeck.c (composite_type): Add FALLTHRU comment. + 2016-08-31 David Malcolm * c-parser.c (c_parser_declaration_or_fndef): Add trailing space diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 51940273d69..fc7a71ef21a 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -605,8 +605,8 @@ composite_type (tree t1, tree t2) t1 = build_function_type (valtype, newargs); t1 = qualify_type (t1, t2); - /* ... falls through ... */ } + /* FALLTHRU */ default: return build_type_attribute_variant (t1, attributes); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c553796d7bf..e68ee629600 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2016-09-01 Marek Polacek + + PR c/7652 + * error.c (dump_type): Fix falls through comment. + (dump_decl): Likewise. + (dump_expr): Likewise. + 2016-08-30 David Malcolm * parser.c (cp_parser_enclosed_template_argument_list): Add fix-it diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 58cd48c0a14..88049ee8f1a 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -575,7 +575,7 @@ dump_type (cxx_pretty_printer *pp, tree t, int flags) default: pp_unsupported_tree (pp, t); - /* Fall through to error. */ + /* Fall through. */ case ERROR_MARK: pp_string (pp, M_("")); @@ -1276,7 +1276,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) default: pp_unsupported_tree (pp, t); - /* Fall through to error. */ + /* Fall through. */ case ERROR_MARK: pp_string (pp, M_("")); @@ -2777,7 +2777,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) `report_error_function'. That could cause an infinite loop. */ default: pp_unsupported_tree (pp, t); - /* fall through to ERROR_MARK... */ + /* Fall through. */ case ERROR_MARK: pp_string (pp, M_("")); break; -- 2.30.2