Skip to content

Commit 8e2006a

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 872301c commit 8e2006a

File tree

8 files changed

+33
-22
lines changed

8 files changed

+33
-22
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 -fPIC
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 -fPIC
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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ EX namespace bt {
284284
else
285285
return path(h, 4, 2, {3, 4, 1});
286286
}
287+
break;
287288
}
288289
case gTernary: {
289290
switch(d) {
@@ -302,6 +303,7 @@ EX namespace bt {
302303
else
303304
return path(h, 5, 3, {4, 5, 2});
304305
}
306+
break;
305307
}
306308
#if MAXMDIM >= 4
307309
case gBinary3: {
@@ -376,6 +378,7 @@ EX namespace bt {
376378
else if(s == d-3) return path(h, d, d, {7, 0});
377379
else return path(h, d, d, {7, d, 9-d-s});
378380
}
381+
break;
379382
}
380383
case gHoroHex: {
381384
// the comment is a picture...
@@ -409,8 +412,9 @@ EX namespace bt {
409412
return path(h, 12, (z+1)%3+3, {13, z+6});
410413
}
411414
}
415+
break;
412416
#endif
413-
default: ;
417+
default: break;
414418
}
415419
printf("error: case not handled in binary tiling\n");
416420
breakhere();
@@ -470,6 +474,8 @@ EX namespace bt {
470474
add(-2 * t0 + shift1);
471475
}
472476
}
477+
// WARNING! UNINTENTIONAL FALLTHROUGH??
478+
goto fallthru; fallthru:
473479
case gHoroRec: {
474480
ld r2 = sqrt(2);
475481
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
@@ -533,14 +533,14 @@ void celldrawer::setcolors() {
533533
wcol = fcol;
534534
break;
535535

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

543-
case waMineOpen:
544544
if(wmblack || wmascii) {
545545
wcol &= 0xFEFEFE;
546546
wcol >>= 1;
@@ -555,6 +555,7 @@ void celldrawer::setcolors() {
555555
case waEditStatue:
556556
if(c->land == laCanvas) wcol = c->landparam;
557557
else wcol = (0x125628 * c->wparam) & 0xFFFFFF;
558+
break;
558559

559560
default:
560561
break;
@@ -1382,11 +1383,8 @@ void celldrawer::draw_features() {
13821383
break;
13831384
}
13841385

1385-
case waTrapdoor:
1386-
if(c->land == laZebra) break;
1387-
/* fallthrough */
1388-
1389-
case waClosePlate: case waOpenPlate: {
1386+
case waTrapdoor: case waClosePlate: case waOpenPlate: {
1387+
if (c->wall == waTrapdoor && c->land == laZebra) break;
13901388
shiftmatrix V2 = V;
13911389
if(wmescher && geosupport_football() == 2 && pseudohept(c) && c->land == laPalace) V2 = V * spin(M_PI / c->type);
13921390
if(GDIM == 3) {

expansion.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,9 @@ void celldrawer::do_viewdist() {
577577
celldistance(c, distance_from == dfPlayer ? cwt.at : currentmap->gamestart());
578578
dc = (d != cd) ? 0xFF0000 : 0x00FF00;
579579
label = its(d);
580+
break;
580581
}
581-
case ncNone: ;
582+
case ncNone: break;
582583
}
583584

584585
// string label = its(fieldpattern::getriverdistleft(c)) + its(fieldpattern::getriverdistright(c));
@@ -1026,4 +1027,4 @@ EX int hyperbolic_celldistance(cell *c1, cell *c2) {
10261027
}
10271028
}
10281029

1029-
}
1030+
}

hypgraph.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) {
10721072
if(pconf.skiprope)
10731073
ret = mobius(ret, pconf.skiprope, 1);
10741074
}
1075+
break;
10751076
}
10761077

10771078
case mdGUARD: case mdManual: break;
@@ -1909,7 +1910,10 @@ EX void draw_model_elements() {
19091910
}
19101911

19111912
queuereset(pmodel, PPR::CIRCLE);
1912-
/* fallthrough */
1913+
ld a = -pconf.model_orientation * degree;
1914+
queuestr(shiftless(xspinpush0(a, +pconf.twopoint_param)), vid.xres / 100, "X", ringcolor >> 8);
1915+
queuestr(shiftless(xspinpush0(a, -pconf.twopoint_param)), vid.xres / 100, "X", ringcolor >> 8);
1916+
return;
19131917
}
19141918

19151919
case mdTwoPoint: case mdSimulatedPerspective: {

mymake.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ bool mingw64 = false;
3636

3737
void set_linux() {
3838
preprocessor = "g++ -E";
39-
compiler = "g++ -Wall -Wextra -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-implicit-fallthrough -rdynamic -fdiagnostics-color=always -c";
39+
compiler = "g++ -Wall -Wextra -Wno-maybe-uninitialized -Wno-unused-parameter -rdynamic -fdiagnostics-color=always -c";
4040
linker = "g++ -rdynamic -o hyper";
4141
opts = "-DFHS -DLINUX -I/usr/include/SDL";
4242
libs = " savepng.o -lSDL -lSDL_ttf -lSDL_mixer -lSDL_gfx -lGLEW -lGL -lpng -rdynamic -lpthread -lz";
4343
}
4444

4545
void set_mac() {
4646
preprocessor = "g++ -E";
47-
compiler = "g++ -march=native -W -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-implicit-fallthrough -c";
47+
compiler = "g++ -march=native -W -Wall -Wextra -Wimplicit-fallthrough -pedantic -Wno-unused-parameter -c";
4848
linker = "g++ -o hyper";
4949
opts = "-DMAC -I/usr/local/include";
5050
libs = " savepng.o -L/usr/local/lib -framework AppKit -framework OpenGL -lSDL -lSDLMain -lSDL_gfx -lSDL_mixer -lSDL_ttf -lpng -lpthread -lz";
@@ -53,7 +53,7 @@ void set_mac() {
5353
void set_mingw64() {
5454
mingw64 = true;
5555
preprocessor = "g++ -E";
56-
compiler = "g++ -mwindows -march=native -W -Wall -Wextra -Werror -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -c";
56+
compiler = "g++ -mwindows -march=native -W -Wall -Wextra -Werror -Wno-unused-parameter -Wno-maybe-uninitialized -c";
5757
linker = "g++ -o hyper";
5858
opts = "-DWINDOWS -DCAP_GLEW=1 -DCAP_PNG=1";
5959
libs = " savepng.o hyper.res -lopengl32 -lSDL -lSDL_gfx -lSDL_mixer -lSDL_ttf -lpthread -lz -lglew32 -lpng";

nonisotropic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ EX namespace sn {
427427
case 8:
428428
return xpush(bw*(4.5-j)) * zpush(-1) * ypush(bw*(i-7));
429429
}
430+
break;
430431
}
431432

432433
default: throw "not nihsolv";

pattern2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,7 @@ EX namespace patterns {
17471747
if(arcm::in()) return colortables['A'][arcm::current.tilegroup[arcm::id_of(c->master)]];
17481748
#endif
17491749
if(arb::in()) return colortables['A'][c->master->zebraval + c->master->emeraldval * isize(arb::current.shapes)];
1750+
return colortables['B'][c->type & 15];
17501751
case 'B':
17511752
return colortables['B'][c->type & 15];
17521753
#if CAP_FIELD

0 commit comments

Comments
 (0)