#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_FORMAT_NONLITERAL _Pragma("clang diagnostic pop")
+#define RESTORE_WARNING_UNREACHABLE_CODE _Pragma("clang diagnostic pop")
#define RESTORE_WARNINGS _Pragma("clang diagnostic pop")
#define STDC_Pragma_AVAILABLE
#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_FORMAT_NONLITERAL _Pragma("GCC diagnostic pop")
+#define RESTORE_WARNING_UNREACHABLE_CODE _Pragma("GCC diagnostic pop")
#define RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
#define STDC_Pragma_AVAILABLE
_Pragma("warning( disable : 4127 )")
#define RESTORE_WARNING_CONDEXPR_IS_CONSTANT _Pragma("warning( pop )")
#define RESTORE_WARNING_FORMAT_NONLITERAL _Pragma("warning( pop )")
+#define RESTORE_WARNING_UNREACHABLE_CODE _Pragma("warning( pop )")
#define RESTORE_WARNINGS _Pragma("warning( pop )")
#define STDC_Pragma_AVAILABLE
#else /* Visual Studio prior to 2019 below */
__pragma(warning(disable:4127))
#define RESTORE_WARNING_CONDEXPR_IS_CONSTANT __pragma(warning(pop))
#define RESTORE_WARNING_FORMAT_NONLITERAL __pragma(warning(pop))
+#define RESTORE_WARNING_UNREACHABLE_CODE __pragma(warning(pop))
#define RESTORE_WARNINGS __pragma(warning(pop))
#define STDC_Pragma_AVAILABLE
#endif /* vs2019 or vs2017 */
#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_FORMAT_NONLITERAL
+#define RESTORE_WARNING_UNREACHABLE_CODE
#define RESTORE_WARNINGS
#endif
/* 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);
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
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",
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 (MON_WEP(mon) && MON_WEP(mon)->otyp == ELVEN_BOW)
+ hitv++;
+ if (singleobj->otyp == ELVEN_ARROW)
+ dam++;
+ }
+ if (bigmonst(g.youmonst.data))
hitv++;
- if (singleobj->otyp == ELVEN_ARROW)
- dam++;
+ 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];
}
}
+DISABLE_WARNING_UNREACHABLE_CODE
+
void
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
return TRUE;
}
+DISABLE_WARNING_UNREACHABLE_CODE
+
/*
* Create a new door in a room.
* It's placed on a wall (north, south, east or west).
default:
x = y = 0;
panic("create_door: No wall for door!");
+ /*UNREACHABLE_CODE*/
goto outdirloop;
}
outdirloop:
levl[x][y].doormask = dd->mask;
}
+RESTORE_WARNING_UNREACHABLE_CODE
+
/*
* Create a secret door in croom on any one of the specified walls.
*/
CFLAGS+=-pedantic
CFLAGS+=-Wmissing-declarations
CFLAGS+=-Wformat-nonliteral
-# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so
-# # leave it out by default.
-# #CFLAGS+=-Wunreachable-code
-# #
+CFLAGS+=-Wunreachable-code
#
# the following are not allowed in C++
CFLAGS+=-Wimplicit
void panic(const char *, ...);
DISABLE_WARNING_FORMAT_NONLITERAL
+DISABLE_WARNING_UNREACHABLE_CODE
void panic
VA_DECL(const char *, str)
abort(); /* generate core dump */
#endif
VA_END();
+ /* UNREACHABLE_CODE */
exit(EXIT_FAILURE); /* redundant */
}
+RESTORE_WARNING_UNREACHABLE_CODE
RESTORE_WARNING_FORMAT_NONLITERAL
#ifdef ALLOCA_HACK