Skip to content

Commit

Permalink
Use c++17 fallthrough attribute when C++17 is enabled or just a comme…
Browse files Browse the repository at this point in the history
…nt "falls through" as a fallback
  • Loading branch information
Sergey Il'inykh committed Dec 28, 2017
1 parent 3163bf4 commit a061cc3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
#include <QColor>
#include <QGridLayout>

#if __cplusplus < 201703L
# define PSI_FALLSTHROUGH
#else
# define PSI_FALLSTHROUGH [[fallthrough]]
#endif

class QMenu;
class TabbableWidget;

Expand Down
2 changes: 1 addition & 1 deletion src/historydlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ void DisplayProxy::handleResult()
break;
case ReqLatest:
can_forward = false;
__attribute__((fallthrough));
PSI_FALLSTHROUGH; // falls through
case ReqNext:
case ReqPrevious:
displayResult(r, queryParams.direction);
Expand Down
2 changes: 1 addition & 1 deletion src/messageview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ QVariantMap MessageView::toVariantMap(bool isMuc, bool formatted) const
case MUCJoin:
case MUCPart:
m["nopartjoin"] = isJoinLeaveHidden();
__attribute__((fallthrough));
PSI_FALLSTHROUGH; // falls through
case Status:
m["sender"] = _nick;
m["status"] = _status;
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/psitiplabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "psirichtext.h"
#include "psioptions.h"
#include "common.h"

PsiTipLabel *PsiTipLabel::instance_ = 0;

Expand Down Expand Up @@ -244,7 +245,7 @@ bool PsiTipLabel::eventFilter(QObject *, QEvent *e)
|| (key == Qt::Key_Shift || key == Qt::Key_Control
|| key == Qt::Key_Alt || key == Qt::Key_Meta))
break;
__attribute__((fallthrough));
PSI_FALLSTHROUGH; // falls through
}
case QEvent::Leave:
case QEvent::WindowActivate:
Expand Down

0 comments on commit a061cc3

Please sign in to comment.