re-enable -Wunreachable-code under clang
whitelist the valid cases showing up If an earlier version of clang is showing more cases (particularly if they don't make sense), the re-enabling of the warning in sys/unix/hints/include/compiler.2020 can be made clang-version specific instead. I had no way to test earlier versions.
This commit is contained in:
@@ -530,11 +530,14 @@ coord_desc(int x, int y, char *outbuf, char cmode)
|
||||
/* for normal map sizes, force a fixed-width formatting so that
|
||||
/m, /M, /o, and /O output lines up cleanly; map sizes bigger
|
||||
than Nx999 or 999xM will still work, but not line up like normal
|
||||
when displayed in a column setting */
|
||||
when displayed in a column setting.
|
||||
|
||||
The (100) is placed in brackets below to mark the [: "03"] as
|
||||
explicit compile-time dead code for clang */
|
||||
if (!*screen_fmt)
|
||||
Sprintf(screen_fmt, "[%%%sd,%%%sd]",
|
||||
(ROWNO - 1 + 2 < 100) ? "02" : "03",
|
||||
(COLNO - 1 < 100) ? "02" : "03");
|
||||
(ROWNO - 1 + 2 < (100)) ? "02" : "03",
|
||||
(COLNO - 1 < (100)) ? "02" : "03");
|
||||
/* map line 0 is screen row 2;
|
||||
map column 0 isn't used, map column 1 is screen column 1 */
|
||||
Sprintf(outbuf, screen_fmt, y + 2, x);
|
||||
|
||||
@@ -923,7 +923,10 @@ set_savefile_name(boolean regularize_it)
|
||||
overflow = 2;
|
||||
}
|
||||
#ifdef SAVE_EXTENSION
|
||||
if (strlen(SAVE_EXTENSION) > 0 && !overflow) {
|
||||
/* (0) is placed in brackets below so that the [&& !overflow] is
|
||||
explicit dead code (the ">" comparison is detected as always
|
||||
FALSE at compile-time). Done to appease clang's -Wunreachable-code */
|
||||
if (strlen(SAVE_EXTENSION) > (0) && !overflow) {
|
||||
if (strlen(g.SAVEF) + strlen(SAVE_EXTENSION) < (SAVESIZE - 1)) {
|
||||
Strcat(g.SAVEF, SAVE_EXTENSION);
|
||||
#ifdef MSDOS
|
||||
|
||||
@@ -579,10 +579,9 @@ m_throw(
|
||||
potionhit(&g.youmonst, singleobj, POTHIT_MONST_THROW);
|
||||
break;
|
||||
}
|
||||
|
||||
oldumort = u.umortality;
|
||||
|
||||
switch (singleobj->otyp) {
|
||||
int dam, hitv;
|
||||
case EGG:
|
||||
if (!touch_petrifies(&mons[singleobj->corpsenm])) {
|
||||
impossible("monster throwing egg type %d",
|
||||
@@ -596,24 +595,28 @@ m_throw(
|
||||
hitu = thitu(8, 0, &singleobj, (char *) 0);
|
||||
break;
|
||||
default:
|
||||
dam = dmgval(singleobj, &g.youmonst);
|
||||
hitv = 3 - distmin(u.ux, u.uy, mon->mx, mon->my);
|
||||
if (hitv < -4)
|
||||
hitv = -4;
|
||||
if (is_elf(mon->data)
|
||||
&& objects[singleobj->otyp].oc_skill == P_BOW) {
|
||||
hitv++;
|
||||
if (MON_WEP(mon) && MON_WEP(mon)->otyp == ELVEN_BOW)
|
||||
{
|
||||
int dam, hitv;
|
||||
|
||||
dam = dmgval(singleobj, &g.youmonst);
|
||||
hitv = 3 - distmin(u.ux, u.uy, mon->mx, mon->my);
|
||||
if (hitv < -4)
|
||||
hitv = -4;
|
||||
if (is_elf(mon->data)
|
||||
&& objects[singleobj->otyp].oc_skill == P_BOW) {
|
||||
hitv++;
|
||||
if (singleobj->otyp == ELVEN_ARROW)
|
||||
dam++;
|
||||
if (MON_WEP(mon) && MON_WEP(mon)->otyp == ELVEN_BOW)
|
||||
hitv++;
|
||||
if (singleobj->otyp == ELVEN_ARROW)
|
||||
dam++;
|
||||
}
|
||||
if (bigmonst(g.youmonst.data))
|
||||
hitv++;
|
||||
hitv += 8 + singleobj->spe;
|
||||
if (dam < 1)
|
||||
dam = 1;
|
||||
hitu = thitu(hitv, dam, &singleobj, (char *) 0);
|
||||
}
|
||||
if (bigmonst(g.youmonst.data))
|
||||
hitv++;
|
||||
hitv += 8 + singleobj->spe;
|
||||
if (dam < 1)
|
||||
dam = 1;
|
||||
hitu = thitu(hitv, dam, &singleobj, (char *) 0);
|
||||
}
|
||||
if (hitu && singleobj->opoisoned && is_poisonable(singleobj)) {
|
||||
char onmbuf[BUFSZ], knmbuf[BUFSZ];
|
||||
|
||||
@@ -116,6 +116,8 @@ l_nhcore_call(int callidx)
|
||||
}
|
||||
}
|
||||
|
||||
DISABLE_WARNING_UNREACHABLE_CODE
|
||||
|
||||
void
|
||||
nhl_error(lua_State *L, const char *msg)
|
||||
{
|
||||
@@ -136,8 +138,11 @@ nhl_error(lua_State *L, const char *msg)
|
||||
#endif
|
||||
(void) lua_error(L);
|
||||
/*NOTREACHED*/
|
||||
/* UNREACHABLE_CODE */
|
||||
}
|
||||
|
||||
RESTORE_WARNING_UNREACHABLE_CODE
|
||||
|
||||
/* Check that parameters are nothing but single table,
|
||||
or if no parameters given, put empty table there */
|
||||
void
|
||||
|
||||
@@ -1570,6 +1570,8 @@ create_subroom(
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DISABLE_WARNING_UNREACHABLE_CODE
|
||||
|
||||
/*
|
||||
* Create a new door in a room.
|
||||
* It's placed on a wall (north, south, east or west).
|
||||
@@ -1659,6 +1661,7 @@ create_door(room_door* dd, struct mkroom* broom)
|
||||
default:
|
||||
x = y = 0;
|
||||
panic("create_door: No wall for door!");
|
||||
/*UNREACHABLE_CODE*/
|
||||
goto outdirloop;
|
||||
}
|
||||
outdirloop:
|
||||
@@ -1675,6 +1678,8 @@ create_door(room_door* dd, struct mkroom* broom)
|
||||
levl[x][y].doormask = dd->mask;
|
||||
}
|
||||
|
||||
RESTORE_WARNING_UNREACHABLE_CODE
|
||||
|
||||
/*
|
||||
* Create a secret door in croom on any one of the specified walls.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user