On Thu, Feb 23, 2017 at 09:07:59PM +0400, Roman Bogorodskiy wrote: > Daniel P. Berrange wrote: > > > On Wed, Feb 22, 2017 at 05:52:05PM +0000, Daniel P. Berrange wrote: > > > In GCC 7 there is a new warning triggered when a switch > > > case has a conditional statement (eg if ... else...) and > > > some of the code paths fallthrough to the next switch > > > statement. e.g. > > > > > > conf/domain_conf.c: In function 'virDomainChrEquals': > > > conf/domain_conf.c:14926:12: error: this statement may fall through [-Werror=implicit-fallthrough=] > > > if (src->targetTypeAttr != tgt->targetTypeAttr) > > > ^ > > > conf/domain_conf.c:14928:5: note: here > > > case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: > > > ^~~~ > > > conf/domain_conf.c: In function 'virDomainChrDefFormat': > > > conf/domain_conf.c:22143:12: error: this statement may fall through [-Werror=implicit-fallthrough=] > > > if (def->targetTypeAttr) { > > > ^ > > > conf/domain_conf.c:22151:5: note: here > > > default: > > > ^~~~~~~ > > > > > > GCC introduced a __attribute__((fallthrough)) to let you > > > indicate that this is intentionale behaviour rather than > > > a bug. > > > > > > BTW, CLang has apparently had an -Wimplicit-fallthrough > > warning flag for a while, and also seems to have the same > > __attribute__((fallthrough)), but I've been unable to get > > CLang to trigger such warnings, and hence did not enable > > __attribute__((fallthrough)) on CLang. If someone can > > figure out how to reproduce the warnings on clang we > > could extend internal.h to surpress them for whichever > > clang version introduced the warnings. As is, the > > ATTRIBUTE_FALLTHROUGH turns into a no-op for CLang unless > > it claims GCC 7.0 compatibility. > > It *looks* like -Wimplicit-fallthrough in clang is only effective for > C++11: > > http://clang-developers.42468.n3.nabble.com/should-Wimplicit-fallthrough-require-C-11-td4028144.html > > It mentions this commit: > > http://llvm.org/viewvc/llvm-project?revision=167655&view=revision > > And it seems it wasn't changed since than. Ah I see. So they disabled it for C, because their [[clang::fallthrough]] magic annotation would not work under C. Hopefully they'll enable it one day with the more normal __attribute__((fallthrough)) syntax for C. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list