Skip to content

Commit fe6e02e

Browse files
authored
Avoid -Wimplicit-fallthrough warnings (#1505)
* add -Wimplicit-fallthrough * add explicit fallthrough comments * update ChangeLog
1 parent 3ad32e8 commit fe6e02e

5 files changed

Lines changed: 17 additions & 7 deletions

File tree

.github/workflows/werror.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
env:
1010
_R_CHECK_FORCE_SUGGESTS_: "false"
11-
RCPP_CXXFLAGS: "-Werror -Wcast-function-type -Wdeprecated-copy"
11+
RCPP_CXXFLAGS: "-Werror -Wcast-function-type -Wdeprecated-copy -Wimplicit-fallthrough"
1212

1313
jobs:
1414
ci:

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
copy operator to avoid -Wdeprecated-copy warnings
1919
* inst/include/Rcpp/date_datetime/newDatetimeVector.h: Idem
2020

21+
* .github/workflows/werror.yaml: Add -Wimplicit-fallthrough
22+
23+
* inst/include/Rcpp/algo.h: Add explicit fallthrough comments to avoid
24+
-Wimplicit-fallthrough warnings
25+
* inst/include/Rcpp/vector/RangeIndexer.h: Idem
26+
* inst/include/Rcpp/macros/unroll.h: Idem
27+
2128
2026-09-01 Iñaki Ucar <iucar@fedoraproject.org>
2229

2330
* .github/workflows/werror.yaml: Add new CI file with -Werror enabled

inst/include/Rcpp/algo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,17 @@ inline bool __any( RandomAccessIterator __first, RandomAccessIterator __last, co
6464
if (*__first == __val)
6565
return true;
6666
++__first;
67+
// fallthrough
6768
case 2:
6869
if (*__first == __val)
6970
return true;
7071
++__first;
72+
// fallthrough
7173
case 1:
7274
if (*__first == __val)
7375
return true;
7476
++__first;
77+
// fallthrough
7578
case 0:
7679
default:
7780
return false;

inst/include/Rcpp/macros/unroll.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ for ( ; __trip_count > 0 ; --__trip_count) { \
3333
} \
3434
switch (n - i){ \
3535
case 3: \
36-
*TARGET++ = SOURCE[i++] ; \
36+
*TARGET++ = SOURCE[i++] ; /* fallthrough */ \
3737
case 2: \
38-
*TARGET++ = SOURCE[i++] ; \
38+
*TARGET++ = SOURCE[i++] ; /* fallthrough */ \
3939
case 1: \
40-
*TARGET++ = SOURCE[i++] ; \
40+
*TARGET++ = SOURCE[i++] ; /* fallthrough */ \
4141
case 0: \
4242
default: \
4343
{} \

inst/include/Rcpp/vector/RangeIndexer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
} \
3636
switch (size_ - i){ \
3737
case 3: \
38-
start[i] OP input[i] ; i++ ; \
38+
start[i] OP input[i] ; i++ ; /* fallthrough */ \
3939
case 2: \
40-
start[i] OP input[i] ; i++ ; \
40+
start[i] OP input[i] ; i++ ; /* fallthrough */ \
4141
case 1: \
42-
start[i] OP input[i] ; i++ ; \
42+
start[i] OP input[i] ; i++ ; /* fallthrough */ \
4343
case 0: \
4444
default: \
4545
return *this ; \

0 commit comments

Comments
 (0)