Skip to content

Commit

Permalink
Add -Wimplicit-fallthrough.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Quuxplusone committed Apr 30, 2020
1 parent 97c9be0 commit 7ba2ce8
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Makefile.simple
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ endif
ifeq (${TOOLCHAIN},clang)
CXXFLAGS_STD = -std=c++11
CXXFLAGS_EARLY += -march=native
CXXFLAGS_EARLY += -W -Wall -Wextra -Werror -pedantic
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-unknown-warning-option
CXXFLAGS_EARLY += -W -Wall -Wextra -Wimplicit-fallthrough -Werror -pedantic
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-maybe-uninitialized -Wno-unknown-warning-option
endif

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

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


Expand Down
2 changes: 2 additions & 0 deletions binary-tiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ EX namespace bt {
add(-2 * t0 + shift1);
}
}
// WARNING! UNINTENTIONAL FALLTHROUGH??
goto fallthru; fallthru:
case gHoroRec: {
ld r2 = sqrt(2);
for(int y=-1; y<=1; y++) for(int x=-1; x<=1; x+=2) for(int z=-1; z<=1; z++)
Expand Down
20 changes: 9 additions & 11 deletions celldrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,14 @@ void celldrawer::setcolors() {
wcol = fcol;
break;

case waMineUnknown: case waMineMine:
if(mine::marked_safe(c))
fcol = wcol = gradient(wcol, 0x40FF40, 0, 0.2, 1);
case waMineUnknown: case waMineMine: case waMineOpen:
if(c->wall == waMineOpen)
;
else if(mine::marked_safe(c))
wcol = gradient(wcol, 0x40FF40, 0, 0.2, 1);
else if(mine::marked_mine(c))
fcol = wcol = gradient(wcol, 0xFF4040, -1, sintick(100), 1);
// fallthrough
wcol = gradient(wcol, 0xFF4040, -1, sintick(100), 1);

case waMineOpen:
if(wmblack || wmascii) {
wcol &= 0xFEFEFE;
wcol >>= 1;
Expand All @@ -554,6 +554,7 @@ void celldrawer::setcolors() {
case waEditStatue:
if(c->land == laCanvas) wcol = c->landparam;
else wcol = (0x125628 * c->wparam) & 0xFFFFFF;
break;

default:
break;
Expand Down Expand Up @@ -1345,11 +1346,8 @@ void celldrawer::draw_features() {
break;
}

case waTrapdoor:
if(c->land == laZebra) break;
/* fallthrough */

case waClosePlate: case waOpenPlate: {
case waTrapdoor: case waClosePlate: case waOpenPlate: {
if (c->wall == waTrapdoor && c->land == laZebra) break;
transmatrix V2 = V;
if(wmescher && geosupport_football() == 2 && pseudohept(c) && c->land == laPalace) V2 = V * spin(M_PI / c->type);
if(GDIM == 3) {
Expand Down
3 changes: 2 additions & 1 deletion expansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ void celldrawer::do_viewdist() {
celldistance(c, distance_from == dfPlayer ? cwt.at : currentmap->gamestart());
dc = (d != cd) ? 0xFF0000 : 0x00FF00;
label = its(d);
break;
}
case ncNone: ;
}
Expand Down Expand Up @@ -927,4 +928,4 @@ EX int hyperbolic_celldistance(cell *c1, cell *c2) {
}
}

}
}
6 changes: 5 additions & 1 deletion hypgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) {
if(pconf.skiprope)
ret = mobius(ret, pconf.skiprope, 1);
}
break;
}

case mdGUARD: case mdManual: break;
Expand Down Expand Up @@ -1650,7 +1651,10 @@ EX void draw_model_elements() {
}

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

case mdTwoPoint: case mdSimulatedPerspective: {
Expand Down
2 changes: 1 addition & 1 deletion mymake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ string preprocessor =
"g++ -E";

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

string linker =
"g++ -rdynamic -o hyper";
Expand Down
1 change: 1 addition & 0 deletions pattern2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,7 @@ EX namespace patterns {
if(arcm::in()) return colortables['A'][arcm::current.tilegroup[arcm::id_of(c->master)]];
#endif
if(arb::in()) return colortables['A'][c->master->zebraval + c->master->emeraldval * isize(arb::current.shapes)];
return colortables['B'][c->type & 15];
case 'B':
return colortables['B'][c->type & 15];
#if CAP_FIELD
Expand Down

0 comments on commit 7ba2ce8

Please sign in to comment.