Skip to content

Commit ecb4021

Browse files
committed
WT-10953: Explicitly mark deliberate fallthrough
Added WT_FALLTHROUGH, which is [[fallthrough]] when using C++17 or higher, or __attribute__((fallthrough)) on GCC-compatible compilers (this covers clang as well). Some fallthroughs were not immediately and obviously correct, so they will need closer investigation.
1 parent 66f4fa7 commit ecb4021

File tree

12 files changed

+52
-8
lines changed

12 files changed

+52
-8
lines changed

src/Wt/Chart/WAbstractGridData.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ void WAbstractGridData::updateGL()
288288
chart_->useProgram(meshProgram_);
289289
chart_->uniformMatrix4(mesh_mvMatrixUniform_, mvMatrix_);
290290
chart_->uniformMatrix4(mesh_pMatrix_, chart_->pMatrix());
291+
// FIXME: suspicious fallthrough
292+
WT_FALLTHROUGH
291293
case Series3DType::Point:
292294
chart_->useProgram(colSeriesProgram_);
293295
chart_->uniformMatrix4(mvMatrixUniform2_, mvMatrix_);

src/Wt/Chart/WCartesianChart.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3379,7 +3379,7 @@ void WCartesianChart::renderLegendIcon(WPainter& painter,
33793379
painter.drawLine(pos.x(), pos.y() + offset, pos.x() + 16, pos.y() + offset);
33803380
painter.setShadow(shadow);
33813381
}
3382-
// no break;
3382+
WT_FALLTHROUGH
33833383
case SeriesType::Point: {
33843384
WPainterPath path;
33853385
drawMarker(series, path);

src/Wt/Dbo/Query.C

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ std::string addLimitQuery(const std::string& sql, const std::string &orderBy, in
102102
result = " select * from ( select row_.*, rownum rownum2 from ( " +
103103
result + " ) row_ where rownum <= ?) where rownum2 > ?";
104104

105+
// FIXME: suspicious fallthrough
106+
WT_FALLTHROUGH
107+
105108
case LimitQuery::OffsetFetch:
106109
if (offset != -1 || limit != -1) {
107110
if (orderBy.empty())

src/Wt/Dbo/WDboDllDefs.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,14 @@
6363
#endif
6464
#endif
6565

66-
#endif // DLLDEFS_H_
66+
#ifndef WT_FALLTHROUGH
67+
#if defined(WT_CXX17)
68+
#define WT_FALLTHROUGH [[fallthrough]];
69+
#elif defined(__GNUC__)
70+
#define WT_FALLTHROUGH __attribute__((fallthrough));
71+
#else
72+
#define WT_FALLTHROUGH
73+
#endif
74+
#endif
75+
76+
#endif // WDBODLLDEFS_H_

src/Wt/WBoxLayout.C

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ std::unique_ptr<WLayoutItem> WBoxLayout::removeItem(WLayoutItem *item)
5757
case LayoutDirection::RightToLeft:
5858
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
5959
index = grid_.columns_.size() - 1 - index;
60+
WT_FALLTHROUGH
6061
case LayoutDirection::LeftToRight: {
6162
result = std::move(grid_.items_[0][index].item_);
6263
grid_.columns_.erase(grid_.columns_.begin() + index);
@@ -66,6 +67,7 @@ std::unique_ptr<WLayoutItem> WBoxLayout::removeItem(WLayoutItem *item)
6667
case LayoutDirection::BottomToTop:
6768
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
6869
index = grid_.rows_.size() - 1 - index;
70+
WT_FALLTHROUGH
6971
case LayoutDirection::TopToBottom: {
7072
result = std::move(grid_.items_[index][0].item_);
7173
grid_.rows_.erase(grid_.rows_.begin() + index);
@@ -85,11 +87,13 @@ WLayoutItem *WBoxLayout::itemAt(int index) const
8587
case LayoutDirection::RightToLeft:
8688
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
8789
index = grid_.columns_.size() - 1 - index;
90+
WT_FALLTHROUGH
8891
case LayoutDirection::LeftToRight:
8992
return grid_.items_[0][index].item_.get();
9093
case LayoutDirection::BottomToTop:
9194
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
9295
index = grid_.rows_.size() - 1 - index;
96+
WT_FALLTHROUGH
9397
case LayoutDirection::TopToBottom:
9498
return grid_.items_[index][0].item_.get();
9599
}
@@ -207,12 +211,14 @@ void WBoxLayout::setStretchFactor(int i, int stretch)
207211
case LayoutDirection::RightToLeft:
208212
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
209213
i = grid_.columns_.size() - 1 - i;
214+
WT_FALLTHROUGH
210215
case LayoutDirection::LeftToRight:
211216
grid_.columns_[i].stretch_ = stretch;
212217
break;
213218
case LayoutDirection::BottomToTop:
214219
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
215220
i = grid_.rows_.size() - 1 - i;
221+
WT_FALLTHROUGH
216222
case LayoutDirection::TopToBottom:
217223
grid_.rows_[i].stretch_ = stretch;
218224
}
@@ -227,6 +233,7 @@ void WBoxLayout::insertItem(int index, std::unique_ptr<WLayoutItem> item,
227233
case LayoutDirection::RightToLeft:
228234
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
229235
index = grid_.columns_.size() - index;
236+
WT_FALLTHROUGH
230237
case LayoutDirection::LeftToRight:
231238
grid_.columns_.insert(grid_.columns_.begin() + index,
232239
Impl::Grid::Section(stretch));
@@ -241,6 +248,7 @@ void WBoxLayout::insertItem(int index, std::unique_ptr<WLayoutItem> item,
241248
case LayoutDirection::BottomToTop:
242249
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
243250
index = grid_.rows_.size() - index;
251+
WT_FALLTHROUGH
244252
case LayoutDirection::TopToBottom:
245253
if (grid_.columns_.empty()) {
246254
grid_.columns_.push_back(Impl::Grid::Section());
@@ -285,13 +293,15 @@ void WBoxLayout::setResizable(int index, bool enabled,
285293
case LayoutDirection::RightToLeft:
286294
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
287295
index = grid_.columns_.size() - 1 - index;
296+
WT_FALLTHROUGH
288297
case LayoutDirection::LeftToRight:
289298
grid_.columns_[index].resizable_ = enabled;
290299
grid_.columns_[index].initialSize_ = initialSize;
291300
break;
292301
case LayoutDirection::BottomToTop:
293302
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
294303
index = grid_.rows_.size() - 1 - index;
304+
WT_FALLTHROUGH
295305
case LayoutDirection::TopToBottom:
296306
grid_.rows_[index].resizable_ = enabled;
297307
grid_.rows_[index].initialSize_ = initialSize;
@@ -306,11 +316,13 @@ bool WBoxLayout::isResizable(int index) const
306316
case LayoutDirection::RightToLeft:
307317
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
308318
index = grid_.columns_.size() - 1 - index;
319+
WT_FALLTHROUGH
309320
case LayoutDirection::LeftToRight:
310321
return grid_.columns_[index].resizable_;
311322
case LayoutDirection::BottomToTop:
312323
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
313324
index = grid_.rows_.size() - 1 - index;
325+
WT_FALLTHROUGH
314326
case LayoutDirection::TopToBottom:
315327
return grid_.rows_[index].resizable_;
316328
}

src/Wt/WDate.C

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ bool WDate::writeSpecial(const std::string& f, unsigned& i,
682682
return true;
683683
}
684684
}
685+
WT_FALLTHROUGH
685686
default:
686687
return false;
687688
}

src/Wt/WDllDefs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,14 @@ typedef unsigned __int32 uint32_t; /* 32 bit unsigned */
102102
#endif
103103
#endif
104104

105+
#ifndef WT_FALLTHROUGH
106+
#if defined(WT_CXX17)
107+
#define WT_FALLTHROUGH [[fallthrough]];
108+
#elif defined(__GNUC__)
109+
#define WT_FALLTHROUGH __attribute__((fallthrough));
110+
#else
111+
#define WT_FALLTHROUGH
112+
#endif
113+
#endif
114+
105115
#endif // DLLDEFS_H_

src/Wt/WTableView.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ void WTableView::render(WFlags<RenderFlag> flags)
925925
break;
926926
case RenderState::NeedUpdateModelIndexes:
927927
updateModelIndexes();
928-
/* fallthrough */
928+
WT_FALLTHROUGH
929929
case RenderState::NeedAdjustViewPort:
930930
adjustToViewport();
931931
break;

src/Wt/WTime.C

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ WDateTime::CharState WTime::handleSpecial(char c, const std::string& v,
226226
return WDateTime::CharState::CharHandled;
227227
}
228228

229-
/* fall through */
229+
WT_FALLTHROUGH
230230

231231
default:
232232
if (!parseLast(v, vi, parse, format))
@@ -668,6 +668,8 @@ WTime::RegExpInfo WTime::formatToRegExp(const WT_USTRING& format)
668668
result.regexp += f[i];
669669
else
670670
inQuote = !inQuote;
671+
// FIXME: suspicious fallthrough
672+
WT_FALLTHROUGH
671673
case 'h':
672674
case 'H':
673675
formatHourToRegExp(result, f, i, currentGroup);

src/http/RequestParser.C

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,9 +1104,8 @@ boost::tribool& RequestParser::consume(Request& req, char *it)
11041104
{
11051105
consumeToString(req.headers.back().value, MAX_FIELD_VALUE_SIZE);
11061106
httpState_ = header_value;
1107-
1108-
/* fall through */
11091107
}
1108+
WT_FALLTHROUGH
11101109
case header_value:
11111110
if (input == '\r')
11121111
{

0 commit comments

Comments
 (0)