From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Rini Date: Wed, 13 May 2020 10:42:00 -0400 Subject: [PATCH 1/1] tools: ftdgrep: use /* fallthrough */ as needed In-Reply-To: <20200513030438.GE5091@bill-the-cat> References: <20200509151242.68082-1-xypron.glpk@gmx.de> <20200511184045.GP12564@bill-the-cat> <87e8b987-dcd6-b2ae-96d4-6e3cfbb76662@gmx.de> <20200513030438.GE5091@bill-the-cat> Message-ID: <20200513144200.GF5091@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, May 12, 2020 at 11:04:38PM -0400, Tom Rini wrote: > On Mon, May 11, 2020 at 09:08:03PM +0200, Heinrich Schuchardt wrote: > > On 5/11/20 8:40 PM, Tom Rini wrote: > > > On Sun, May 10, 2020 at 10:12:07PM +0900, Masahiro Yamada wrote: > > >> On Sun, May 10, 2020 at 12:12 AM Heinrich Schuchardt wrote: > > >>> > > >>> GCC recognizes /* fallthrough */ if -Wimplicit-fallthrough=3 is enabled. > > >> > > >> FYI. > > >> > > >> Linux decided to not use /* fallthrough */ any more > > >> because Clang does not recognize it. > > >> > > >> __attribute__((__fallthrough__)) is supported > > >> by both Clang and recent GCC. > > In fact Linux has a define: > > > > include/linux/compiler_attributes.h:200:# define fallthrough > > __attribute__((__fallthrough__)) > > > > And in the code you would use > > > > case foo: > > fallthrough; > > case bar: > > > > But the Linux kernel still has a lot of lines with > > > > /* fallthrough */ > > > > Documentation/process/deprecated.rst: > > > > > > As there have been a long list of flaws `due to missing "break" > > statements `_, we no > > longer allow implicit fall-through. In order to identify intentional > > fall-through cases, we have adopted a pseudo-keyword macro "fallthrough" > > which expands to gcc's extension `__attribute__((__fallthrough__)) > > `_. (When > > the C17/C18 `[[fallthrough]]` syntax is more commonly supported by C > > compilers, static analyzers, and IDEs, we can switch to using that > > syntax for the macro pseudo-keyword.) > > > > > > Using the attribute is not standard C and not any better than using the > > comment. The real target is the C17 syntax. > > > > >> > > >> > > >> Linux is now doing treewide conversion > > >> from /* fallthrough */ to 'fallthrough;'. > > >> > > >> See include/linux/compiler_attributes.h in Linux. > > >> > > >> I do not know if U-Boot wants to align with it. > > >> (up to Tom ?) > > > > > > A re-sync on the compiler headers again and making use of this sounds > > > like a good idea, yes. > > > > > > > We should enable -Wimplicit-fallthrough like the kernel does. This > > defaults to -Wimplicit-fallthrough=3 and is happy with both the comment > > as well as with the attribute. > > > > @Tom: > > Will you update the compiler headers within this release cycle? > > Otherwise we should take the patch as is to get us closer to the > > -Wimplicit-fallthrough target. > > I'm not going to update it for this release cycle. I've done the > initial import and build and there's some fairly large changes related > to inlining that I want to look at harder to see if we can/should do > something about (I don't want to derail this thread, I'll start > another). But it's very far from zero size change and given the inline > changes I think it'll need real testing. > > And since the kernel isn't making a huge use yet of fallthrough; we can > afford to look a little harder at things. I think I've figured out the inline issue which is that we need scripts/Kconfig.include from the kernel, CC_HAS_ASM_INLINE Kconfig option, and re-sync with Kconfiglib, but that's still going to be enough stuff that I don't think it's good to pull in at -rc2. -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: