Skip to content

Commit 7ba2ce8

Browse files
committed
Add -Wimplicit-fallthrough.
Clang doesn't enable this warning by default, so we pass it explicitly. GCC pre-GCC 7 doesn't recognize the flag, so we can't pass it for GCC. GCC 7 enables it by default as part of -Wextra.
1 parent 97c9be0 commit 7ba2ce8

File tree

7 files changed

+24
-18
lines changed

7 files changed

+24
-18
lines changed

Makefile.simple

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,22 @@ endif
8282
ifeq (${TOOLCHAIN},clang)
8383
CXXFLAGS_STD = -std=c++11
8484
CXXFLAGS_EARLY += -march=native
85-
CXXFLAGS_EARLY += -W -Wall -Wextra -Werror -pedantic
86-
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-unknown-warning-option
85+
CXXFLAGS_EARLY += -W -Wall -Wextra -Wimplicit-fallthrough -Werror -pedantic
86+
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-maybe-uninitialized -Wno-unknown-warning-option
8787
endif
8888

8989
ifeq (${TOOLCHAIN},gcc)
9090
CXXFLAGS_STD = -std=c++11
9191
CXXFLAGS_EARLY += -march=native
9292
CXXFLAGS_EARLY += -W -Wall -Wextra -Werror -pedantic
93-
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized
93+
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-maybe-uninitialized
9494
endif
9595

9696
ifeq (${TOOLCHAIN},mingw)
9797
CXXFLAGS_STD = -std=c++11
9898
CXXFLAGS_EARLY += -march=native
9999
CXXFLAGS_EARLY += -W -Wall -Wextra -Werror
100-
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized
100+
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-maybe-uninitialized
101101
endif
102102

103103

binary-tiling.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,8 @@ EX namespace bt {
486486
add(-2 * t0 + shift1);
487487
}
488488
}
489+
// WARNING! UNINTENTIONAL FALLTHROUGH??
490+
goto fallthru; fallthru:
489491
case gHoroRec: {
490492
ld r2 = sqrt(2);
491493
for(int y=-1; y<=1; y++) for(int x=-1; x<=1; x+=2) for(int z=-1; z<=1; z++)

celldrawer.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,14 @@ void celldrawer::setcolors() {
532532
wcol = fcol;
533533
break;
534534

535-
case waMineUnknown: case waMineMine:
536-
if(mine::marked_safe(c))
537-
fcol = wcol = gradient(wcol, 0x40FF40, 0, 0.2, 1);
535+
case waMineUnknown: case waMineMine: case waMineOpen:
536+
if(c->wall == waMineOpen)
537+
;
538+
else if(mine::marked_safe(c))
539+
wcol = gradient(wcol, 0x40FF40, 0, 0.2, 1);
538540
else if(mine::marked_mine(c))
539-
fcol = wcol = gradient(wcol, 0xFF4040, -1, sintick(100), 1);
540-
// fallthrough
541+
wcol = gradient(wcol, 0xFF4040, -1, sintick(100), 1);
541542

542-
case waMineOpen:
543543
if(wmblack || wmascii) {
544544
wcol &= 0xFEFEFE;
545545
wcol >>= 1;
@@ -554,6 +554,7 @@ void celldrawer::setcolors() {
554554
case waEditStatue:
555555
if(c->land == laCanvas) wcol = c->landparam;
556556
else wcol = (0x125628 * c->wparam) & 0xFFFFFF;
557+
break;
557558

558559
default:
559560
break;
@@ -1345,11 +1346,8 @@ void celldrawer::draw_features() {
13451346
break;
13461347
}
13471348

1348-
case waTrapdoor:
1349-
if(c->land == laZebra) break;
1350-
/* fallthrough */
1351-
1352-
case waClosePlate: case waOpenPlate: {
1349+
case waTrapdoor: case waClosePlate: case waOpenPlate: {
1350+
if (c->wall == waTrapdoor && c->land == laZebra) break;
13531351
transmatrix V2 = V;
13541352
if(wmescher && geosupport_football() == 2 && pseudohept(c) && c->land == laPalace) V2 = V * spin(M_PI / c->type);
13551353
if(GDIM == 3) {

expansion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ void celldrawer::do_viewdist() {
513513
celldistance(c, distance_from == dfPlayer ? cwt.at : currentmap->gamestart());
514514
dc = (d != cd) ? 0xFF0000 : 0x00FF00;
515515
label = its(d);
516+
break;
516517
}
517518
case ncNone: ;
518519
}
@@ -927,4 +928,4 @@ EX int hyperbolic_celldistance(cell *c1, cell *c2) {
927928
}
928929
}
929930

930-
}
931+
}

hypgraph.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) {
901901
if(pconf.skiprope)
902902
ret = mobius(ret, pconf.skiprope, 1);
903903
}
904+
break;
904905
}
905906

906907
case mdGUARD: case mdManual: break;
@@ -1650,7 +1651,10 @@ EX void draw_model_elements() {
16501651
}
16511652

16521653
queuereset(pmodel, PPR::CIRCLE);
1653-
/* fallthrough */
1654+
ld a = -pconf.model_orientation * degree;
1655+
queuestr(xspinpush0(a, +pconf.twopoint_param), vid.xres / 100, "X", ringcolor >> 8);
1656+
queuestr(xspinpush0(a, -pconf.twopoint_param), vid.xres / 100, "X", ringcolor >> 8);
1657+
return;
16541658
}
16551659

16561660
case mdTwoPoint: case mdSimulatedPerspective: {

mymake.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ string preprocessor =
2626
"g++ -E";
2727

2828
string compiler =
29-
"g++ -Wall -Wextra -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-implicit-fallthrough -rdynamic -fdiagnostics-color=always -c";
29+
"g++ -Wall -Wextra -Wno-maybe-uninitialized -Wno-unused-parameter -rdynamic -fdiagnostics-color=always -c";
3030

3131
string linker =
3232
"g++ -rdynamic -o hyper";

pattern2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,7 @@ EX namespace patterns {
16851685
if(arcm::in()) return colortables['A'][arcm::current.tilegroup[arcm::id_of(c->master)]];
16861686
#endif
16871687
if(arb::in()) return colortables['A'][c->master->zebraval + c->master->emeraldval * isize(arb::current.shapes)];
1688+
return colortables['B'][c->type & 15];
16881689
case 'B':
16891690
return colortables['B'][c->type & 15];
16901691
#if CAP_FIELD

0 commit comments

Comments
 (0)