D15694: Make implicit fallthroughs a compiler error, remove unneeded breaks

René J.V. Bertin noreply at phabricator.kde.org
Sun Sep 23 18:31:15 BST 2018


rjvbb added a comment.


  As mentioned on another ticket, I don't like the idea of not putting `break`s, no matter how clever the compiler and hard-coded choice of compiler options; I don't think you gain anything from it, and it doesn't improve code readability either for me (esp. when switch cases aren't indented w.r.t the switch context, as in the last hunk in `plugins/qmljs/codecompletion/context.cpp`.
  Making it obligatory to add a token confirming that fallthrough is intended is a good idea, though using a largish term in all-caps like `Q_FALLTHROUGH` also doesn't improve readibilty. And what about the most common type of fallthrough, are we really going to have to write something like the following?
  
    switch (type) {
        case TYPE_A:
            Q_FALLTHROUGH
        case TYPE_B:
            Q_FALLTHROUGH
        case TYPE_C:
            Q_FALLTHROUGH
        case TYPE_D:
            whatever();
            break;
        default:
            anyway();
            // remember not to put a break here
    }

REPOSITORY
  R32 KDevelop

REVISION DETAIL
  https://phabricator.kde.org/D15694

To: aaronpuchert, #kdevelop
Cc: rjvbb, brauch, mssola, kossebau, kdevelop-devel, glebaccon, antismap, iodelay, vbspam, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20180923/6218827f/attachment.html>


More information about the KDevelop-devel mailing list