[cfe-dev] Compiling Clang with -Wimplicit-fallthrough

Luke Zarko zarko at google.com
Thu Jun 13 14:53:27 PDT 2013


What's the feeling about compiling Clang with -Wimplicit-fallthrough
turned on by default? I've gone through the code and have found that
most of the sites it flags are either already called out by comments
or are benign--for example, in lib/Edit/RewriteObjCFoundationAPI.cpp:

  case NSAPI::NSNumberWithUnsignedInt:
  case NSAPI::NSNumberWithUnsignedInteger:
    CallIsUnsigned = true;
  SAFE_IMPLICIT_FALLTHROUGH
  case NSAPI::NSNumberWithInt:
  case NSAPI::NSNumberWithInteger:
    break;

(The behavior of the check seems to be a little conservative here, but
I can come up with arguments for flagging the fallthrough or not
flagging it; as it stands, the test for the feature explicitly checks
that the diagnostic is generated.)

I suppose that one difficulty might be the lack of a
compiler-independent annotation. Some quick searches show that others
have made various proposals before (__builtin_fallthrough(), etc); has
there been any consensus on this?

Thanks
  Luke



More information about the cfe-dev mailing list