From patchwork Mon Jul 11 19:50:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 647049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rpG170Lgfz9s9c for ; Tue, 12 Jul 2016 05:50:50 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=wD/6vNEk; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=bV/zfd+fpkVBAZXAsrJ1GYjArK54wV SZyioNWVuowSCfdG09070zkLfrvPdHtMLRu6R40r0nAIExz+/tu7qQlT4DSm3lL4 KET29aA/HScciFmj/LBnQ76dZVTo4WK57litsxEd24QSs9UQCIcq01F/MQ9XxlMz Gu0pKMc1ReUfY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=sX2dOSdIpKW+yiDVZHkhrixMsXg=; b=wD/6 vNEkLPAdSj+BUCnOl98jRnhGW3yZPj1iJaE0jSRfO8anq+g21DtqTANYTwPeAuUm XmhQlfIeM314sFT+LveTYNvHhKBP13GLwA8eQISV3ffeQsjkAmOwQQr3MU1aBJN3 N2DXfcm2VuI+F6nF+vsex8CfMCKtyrqkiSG73sM= Received: (qmail 113215 invoked by alias); 11 Jul 2016 19:50:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 113202 invoked by uid 89); 11 Jul 2016 19:50:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=*valp, DECL_INITIAL, decl_initial, sk:opt_ftr X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 11 Jul 2016 19:50:40 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C28F47F6A5 for ; Mon, 11 Jul 2016 19:50:39 +0000 (UTC) Received: from redhat.com (ovpn-204-85.brq.redhat.com [10.40.204.85]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6BJoaRZ021572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 11 Jul 2016 15:50:38 -0400 Date: Mon, 11 Jul 2016 21:50:36 +0200 From: Marek Polacek To: GCC Patches Subject: Re: Implement -Wswitch-fallthrough: c-family/ Message-ID: <20160711195036.GL13963@redhat.com> References: <20160711194340.GI13963@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160711194340.GI13963@redhat.com> User-Agent: Mutt/1.6.1 (2016-04-27) 2016-07-11 Marek Polacek PR c/7652 * c-ada-spec.c (print_ada_macros): Add gcc_fallthrough. (to_ada_name): Likewise. (dump_generic_ada_node): Likewise. (dump_nested_type): Likewise. * c-common.c (warn_if_unused_value): Likewise. (sizeof_pointer_memaccess_warning): Likewise. (c_common_truthvalue_conversion): Likewise. (handle_tm_attribute): Likewise. (c_cpp_error): Likewise. (resolve_overloaded_builtin): Likewise. (scalar_to_vector): Likewise. * c-gimplify.c (c_gimplify_expr): Likewise. * c-lex.c (c_lex_with_flags): Likewise. (lex_string): Likewise. * c-omp.c (c_finish_omp_for): Likewise. * c-opts.c (c_common_handle_option): Likewise. * c-pragma.c (handle_pragma_pack): Likewise. * c-pretty-print.c (c_pretty_printer::postfix_expression): Likewise. * cilk.c (extract_free_variables): Likewise. diff --git gcc/gcc/c-family/c-ada-spec.c gcc/gcc/c-family/c-ada-spec.c index e33fdff..04a918f 100644 --- gcc/gcc/c-family/c-ada-spec.c +++ gcc/gcc/c-family/c-ada-spec.c @@ -288,6 +288,7 @@ print_ada_macros (pretty_printer *pp, cpp_hashnode **macros, int max_ada_macros) break; } /* fallthrough */ + gcc_fallthrough (); case CPP_RSHIFT: case CPP_COMPL: @@ -1182,6 +1183,7 @@ to_ada_name (const char *name, int *space_found) if (len2 && s[len2 - 1] == '_') s[len2++] = 'u'; /* fall through */ + gcc_fallthrough (); default: s[len2++] = name[j]; @@ -1862,6 +1864,8 @@ dump_generic_ada_node (pretty_printer *buffer, tree node, tree type, int spc, case TREE_BINFO: dump_generic_ada_node (buffer, BINFO_TYPE (node), type, spc, limited_access, name_only); + /* XXX Really fallthru? */ + gcc_fallthrough (); case TREE_VEC: pp_string (buffer, "--- unexpected node: TREE_VEC"); @@ -2585,6 +2589,7 @@ dump_nested_type (pretty_printer *buffer, tree field, tree t, tree parent, pp_string (buffer, ");"); } } + gcc_fallthrough (); default: break; diff --git gcc/gcc/c-family/c-common.c gcc/gcc/c-family/c-common.c index 936ddfb..0f5f65a 100644 --- gcc/gcc/c-family/c-common.c +++ gcc/gcc/c-family/c-common.c @@ -1506,6 +1506,7 @@ warn_if_unused_value (const_tree exp, location_t locus) goto restart; } /* Fall through. */ + gcc_fallthrough (); default: /* Referencing a volatile value is a side effect, so don't warn. */ @@ -1518,6 +1519,7 @@ warn_if_unused_value (const_tree exp, location_t locus) but front ends may define such. */ if (EXPRESSION_CLASS_P (exp) && TREE_OPERAND_LENGTH (exp) == 0) return false; + gcc_fallthrough (); warn: return warning_at (locus, OPT_Wunused_value, "value computed is not used"); @@ -1629,6 +1631,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, case BUILT_IN_STRNCASECMP: cmp = true; /* FALLTHRU */ + gcc_fallthrough (); case BUILT_IN_STRNCPY: case BUILT_IN_STRNCPY_CHK: case BUILT_IN_STRNCAT: @@ -1637,6 +1640,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, case BUILT_IN_STPNCPY_CHK: strop = true; /* FALLTHRU */ + gcc_fallthrough (); case BUILT_IN_MEMCPY: case BUILT_IN_MEMCPY_CHK: case BUILT_IN_MEMMOVE: @@ -4468,6 +4472,7 @@ c_common_truthvalue_conversion (location_t location, tree expr) case FUNCTION_DECL: expr = build_unary_op (location, ADDR_EXPR, expr, 0); /* Fall through. */ + gcc_fallthrough (); case ADDR_EXPR: { @@ -8739,6 +8744,7 @@ handle_tm_attribute (tree *node, tree name, tree args, if (tm_attr_to_mask (name) & ~(TM_ATTR_SAFE | TM_ATTR_CALLABLE)) goto ignored; /* FALLTHRU */ + gcc_fallthrough (); case FUNCTION_TYPE: case METHOD_TYPE: @@ -8782,11 +8788,13 @@ handle_tm_attribute (tree *node, tree name, tree args, } } /* FALLTHRU */ + gcc_fallthrough (); default: /* If a function is next, pass it on to be tried next. */ if (flags & (int) ATTR_FLAG_FUNCTION_NEXT) return tree_cons (name, args, NULL); + gcc_fallthrough (); ignored: warning (OPT_Wattributes, "%qE attribute ignored", name); @@ -10253,6 +10261,7 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason, return false; global_dc->dc_warn_system_headers = 1; /* Fall through. */ + gcc_fallthrough (); case CPP_DL_WARNING: if (flag_no_output) return false; @@ -11450,6 +11459,7 @@ resolve_overloaded_builtin (location_t loc, tree function, { fetch_op = false; /* Fallthrough to further processing. */ + gcc_fallthrough (); } case BUILT_IN_ATOMIC_ADD_FETCH_N: case BUILT_IN_ATOMIC_SUB_FETCH_N: @@ -11466,6 +11476,7 @@ resolve_overloaded_builtin (location_t loc, tree function, { orig_format = false; /* Fallthru for parameter processing. */ + gcc_fallthrough (); } case BUILT_IN_SYNC_FETCH_AND_ADD_N: case BUILT_IN_SYNC_FETCH_AND_SUB_N: @@ -12623,6 +12634,7 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, case BIT_AND_EXPR: integer_only_op = true; /* ... fall through ... */ + gcc_fallthrough (); case VEC_COND_EXPR: @@ -12678,6 +12690,7 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, } return ret; } + gcc_fallthrough (); default: break; } diff --git gcc/gcc/c-family/c-gimplify.c gcc/gcc/c-family/c-gimplify.c index c18b057..a7a7189 100644 --- gcc/gcc/c-family/c-gimplify.c +++ gcc/gcc/c-family/c-gimplify.c @@ -295,6 +295,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED, cilk_gimplify_call_params_in_spawned_fn (expr_p, pre_p); return (enum gimplify_status) gimplify_cilk_spawn (expr_p); } + gcc_fallthrough (); default:; } diff --git gcc/gcc/c-family/c-lex.c gcc/gcc/c-family/c-lex.c index 8f33d86..634cd20 100644 --- gcc/gcc/c-family/c-lex.c +++ gcc/gcc/c-family/c-lex.c @@ -493,6 +493,7 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags, break; } /* FALLTHROUGH */ + gcc_fallthrough (); default: /* ... or not. */ @@ -504,6 +505,7 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags, } /* FALLTHROUGH */ + gcc_fallthrough (); case CPP_HASH: case CPP_PASTE: { @@ -1127,6 +1129,7 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string, bool translate) goto retry; } /* FALLTHROUGH */ + gcc_fallthrough (); default: break; @@ -1142,6 +1145,8 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string, bool translate) else error ("unsupported non-standard concatenation of string literals"); } + /* XXX Really fallthru? */ + gcc_fallthrough (); case CPP_STRING: if (!concats) diff --git gcc/gcc/c-family/c-omp.c gcc/gcc/c-family/c-omp.c index 1691c40..c0a3e9a 100644 --- gcc/gcc/c-family/c-omp.c +++ gcc/gcc/c-family/c-omp.c @@ -634,6 +634,7 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv, break; incr = TREE_OPERAND (incr, 1); /* FALLTHRU */ + gcc_fallthrough (); case MODIFY_EXPR: if (TREE_OPERAND (incr, 0) != decl) break; diff --git gcc/gcc/c-family/c-opts.c gcc/gcc/c-family/c-opts.c index ff6339c..cb7728d 100644 --- gcc/gcc/c-family/c-opts.c +++ gcc/gcc/c-family/c-opts.c @@ -437,6 +437,7 @@ c_common_handle_option (size_t scode, const char *arg, int value, case OPT_ffreestanding: value = !value; /* Fall through.... */ + gcc_fallthrough (); case OPT_fhosted: flag_hosted = value; flag_no_builtin = !value; @@ -479,6 +480,7 @@ c_common_handle_option (size_t scode, const char *arg, int value, if (value) value = 2; /* Fall Through. */ + gcc_fallthrough (); case OPT_ftrack_macro_expansion_: if (arg && *arg != '\0') diff --git gcc/gcc/c-family/c-pragma.c gcc/gcc/c-family/c-pragma.c index 277bc56..6d38358 100644 --- gcc/gcc/c-family/c-pragma.c +++ gcc/gcc/c-family/c-pragma.c @@ -214,6 +214,8 @@ handle_pragma_pack (cpp_reader * ARG_UNUSED (dummy)) align = maximum_field_alignment; break; } + /* XXX Really fallthru? */ + gcc_fallthrough (); default: GCC_BAD2 ("alignment must be a small power of two, not %d", align); } diff --git gcc/gcc/c-family/c-pretty-print.c gcc/gcc/c-family/c-pretty-print.c index 704d21d..c9ff725 100644 --- gcc/gcc/c-family/c-pretty-print.c +++ gcc/gcc/c-family/c-pretty-print.c @@ -1643,6 +1643,7 @@ c_pretty_printer::postfix_expression (tree e) case COMPOUND_LITERAL_EXPR: e = DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e)); /* Fall through. */ + gcc_fallthrough (); case CONSTRUCTOR: initializer (e); break; @@ -1663,6 +1664,7 @@ c_pretty_printer::postfix_expression (tree e) break; } /* else fall through. */ + gcc_fallthrough (); default: primary_expression (e); diff --git gcc/gcc/c-family/cilk.c gcc/gcc/c-family/cilk.c index 8f34cd6..87ba9f6 100644 --- gcc/gcc/c-family/cilk.c +++ gcc/gcc/c-family/cilk.c @@ -1096,6 +1096,7 @@ extract_free_variables (tree t, struct wrapper_data *wd, case RESULT_DECL: if (wd->type != CILK_BLOCK_SPAWN) TREE_ADDRESSABLE (t) = 1; + gcc_fallthrough (); case VAR_DECL: case PARM_DECL: if (!is_global_var (t))