From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752724AbdBJRuv (ORCPT ); Fri, 10 Feb 2017 12:50:51 -0500 Received: from smtprelay0107.hostedemail.com ([216.40.44.107]:50836 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751555AbdBJRuu (ORCPT ); Fri, 10 Feb 2017 12:50:50 -0500 X-Greylist: delayed 2366 seconds by postgrey-1.27 at vger.kernel.org; Fri, 10 Feb 2017 12:49:50 EST X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:1981:2194:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:4321:5007:6119:6261:7903:10004:10848:11026:11658:11914:12043:12296:12438:12555:12895:13069:13311:13357:14096:14181:14384:14394:14721:21080:21434:21451:30054:30070,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:3,LUA_SUMMARY:none X-HE-Tag: fork79_4b64ed3505a47 X-Filterd-Recvd-Size: 2278 From: Joe Perches To: Arnaldo Carvalho de Melo , Christopher Li Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-sparse@vger.kernel.org Subject: [PATCH] compiler/compiler-gcc: Add __fallthrough Date: Fri, 10 Feb 2017 09:08:35 -0800 Message-Id: <791a2621851fc989bc04dfe975ec29de15cbb557.1486746344.git.joe@perches.com> X-Mailer: git-send-email 2.10.0.rc2.1.g053435c In-Reply-To: <20170210144238.GC15066@kernel.org> References: <20170210144238.GC15066@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc v7.0 can warn on missing break statements from case labels using a special __attribute__((fallthrough))__ marker. Add a __fallthrough convenience macro for gcc versions >= 7 and make the generic use of __fallthrough a no-op. Signed-off-by: Joe Perches --- include/linux/compiler-gcc.h | 7 +++++++ include/linux/compiler.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index d5e1fedbad24..6af8d6448f10 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -304,6 +304,13 @@ #define __no_sanitize_address __attribute__((no_sanitize_address)) #endif +#if GCC_VERSION >= 70000 +/* + * Tell the compiler not to warn when a switch/case fallthrough marker exists + */ +#define __fallthrough __attribute__ ((fallthrough)) +#endif + #endif /* gcc version >= 40000 specific checks */ #if !defined(__noclone) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 6e8e160b1e4b..16b6efc877f4 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -477,6 +477,12 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s #define __assume_aligned(a, ...) #endif +/* + * switch/case fallthrough checking + */ +#ifndef __fallthrough +#define __fallthrough +#endif /* Are two types/vars the same type (ignoring qualifiers)? */ #ifndef __same_type -- 2.10.0.rc2.1.g053435c