#include "ntconf.h"
#endif
+#include "warnings.h"
+
/* amiconf.h needs to be the last nested #include of config.h because
'make depend' will turn it into a comment, hiding anything after it */
#ifdef AMIGA
--- /dev/null
+/* NetHack 3.7 warnings.h $NHDT-Date: 1596498562 2020/08/03 23:49:22 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.24 $ */
+/* Copyright (c) Michael Allison, 2021. */
+
+#ifndef WARNINGS_H
+#define WARNINGS_H
+
+/*
+ * If ENABLE_WARNING_PRAGMAS is defined, the checks for various
+ * compilers is activated.
+ *
+ * If a suitable compiler is found, STDC_Pragma_AVAILABLE will be defined.
+ * When STDC_Pragma_AVAILABLE is not defined, these are defined as no-ops:
+ * DISABLE_WARNING_UNREACHABLE_CODE
+ * DISABLE_WARNING_CONDEXPR_IS_CONSTANT
+ * ...
+ * RESTORE_WARNINGS
+ *
+ */
+
+#if !defined(DISABLE_WARNING_PRAGMAS)
+#if defined(__STDC_VERSION__)
+#if __STDC_VERSION__ >= 199901L
+#define ACTIVATE_WARNING_PRAGMAS
+#endif /* __STDC_VERSION >= 199901L */
+#endif /* __STDC_VERSION */
+#if defined(_MSC_VER)
+#ifndef ACTIVATE_WARNING_PRAGMAS
+#define ACTIVATE_WARNING_PRAGMAS
+#endif
+#endif
+
+#ifdef ACTIVATE_WARNING_PRAGMAS
+#if defined(__clang__)
+#define DISABLE_WARNING_UNREACHABLE_CODE \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Wunreachable-code\"")
+#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT
+#define RESTORE_WARNINGS _Pragma("clang diagnostic pop")
+#define STDC_Pragma_AVAILABLE
+
+#elif defined(__GNUC__)
+/* unlike in clang, -Wunreachable-code does not function in later versions of gcc */
+#define DISABLE_WARNING_UNREACHABLE_CODE \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wunreachable-code\"")
+#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT
+#define RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
+#define STDC_Pragma_AVAILABLE
+
+#elif defined(_MSC_VER)
+#define DISABLE_WARNING_UNREACHABLE_CODE \
+ _Pragma("warning( push )") \
+ _Pragma("warning( disable : 4702 )")
+#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT \
+ _Pragma("warning( push )") \
+ _Pragma("warning( disable : 4127 )")
+#define RESTORE_WARNINGS _Pragma("warning( pop )")
+#define STDC_Pragma_AVAILABLE
+
+#endif /* various compiler detections */
+#endif /* ACTIVATE_WARNING_PRAGMAS */
+#else /* DISABLE_WARNING_PRAGMAS */
+#if defined(STDC_Pragma_AVAILABLE)
+#undef STDC_Pragma_AVAILABLE
+#endif
+#endif /* DISABLE_WARNING_PRAGMAS */
+
+#if !defined(STDC_Pragma_AVAILABLE)
+#define DISABLE_WARNING_UNREACHABLE_CODE
+#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT
+#deifne RESTORE_WARNINGS
+#endif
+
+#endif /* WARNINGS_H */
return;
}
+DISABLE_WARNING_CONDEXPR_IS_CONSTANT
+
/* #wizsmell command - test usmellmon(). */
static int
wiz_smell(void)
return 0;
}
+RESTORE_WARNINGS
+
#define DEFAULT_TIMEOUT_INCR 30
/* #wizinstrinsic command to set some intrinsics for testing */
}
}
+DISABLE_WARNING_UNREACHABLE_CODE
+
static boolean
gather_locs_interesting(int x, int y, int gloc)
{
return FALSE;
}
+RESTORE_WARNINGS
+
/* gather locations for monsters or objects shown on the map */
static void
gather_locs(coord **arr_p, int *cnt_p, int gloc)
return res;
}
+DISABLE_WARNING_UNREACHABLE_CODE
+
int
use_misc(struct monst* mtmp)
{
return 0;
}
+RESTORE_WARNINGS
+
static void
you_aggravate(struct monst* mtmp)
{
return 0;
}
+DISABLE_WARNING_UNREACHABLE_CODE
+
/* local loc = getmap(x,y) */
static int
nhl_getmap(lua_State *L)
return 1;
}
+RESTORE_WARNINGS
+
/* pline("It hits!") */
static int
nhl_pline(lua_State *L)
return ret;
}
+DISABLE_WARNING_CONDEXPR_IS_CONSTANT
+
const char *
get_lua_version(void)
{
}
return (const char *) g.lua_ver;
}
+
+RESTORE_WARNINGS
+
+
+
}
}
+DISABLE_WARNING_UNREACHABLE_CODE
+
int
tactics(struct monst *mtmp)
{
return 0;
}
+RESTORE_WARNINGS
+
/* are there any monsters mon could aggravate? */
boolean
has_aggravatables(struct monst *mon)
#include <stdlib.h>
#endif
+#include "warnings.h"
+
static void decode(FILE *, FILE *);
static void outdec(char *, FILE *, int);
/* single-character decode */
#define DEC(c) (((c) - ' ') & 077)
+DISABLE_WARNING_UNREACHABLE_CODE
+
int
main(int argc, char **argv)
{
return 0;
}
+RESTORE_WARNINGS
+
/*
* copy from in to out, decoding as you go along.
*/
HACKINCL = align.h artifact.h artilist.h attrib.h botl.h \
color.h config.h config1.h context.h coord.h decl.h \
display.h dlb.h dungeon.h engrave.h extern.h flag.h fnamesiz.h \
- func_tab.h global.h hack.h lint.h mextra.h mfndpos.h \
+ func_tab.h global.h warnings.h hack.h lint.h mextra.h mfndpos.h \
micro.h mkroom.h \
monattk.h mondata.h monflag.h monst.h monsym.h obj.h objclass.h \
optlist.h patchlevel.h pcconf.h permonst.h prop.h rect.h \
# config.h timestamp
$(CONFIG_H): ../include/config.h ../include/config1.h ../include/patchlevel.h \
- ../include/tradstdc.h ../include/global.h ../include/coord.h \
- ../include/vmsconf.h ../include/system.h ../include/nhlua.h \
- ../include/unixconf.h ../include/pcconf.h ../include/micro.h \
+ ../include/tradstdc.h ../include/global.h ../include/warnings.h \
+ ../include/coord.h ../include/vmsconf.h ../include/system.h \
+ ../include/nhlua.h ../include/unixconf.h ../include/pcconf.h \
../include/ntconf.h ../include/fnamesiz.h
touch $(CONFIG_H)
# hack.h timestamp
#else /* ! MAC */
+DISABLE_WARNING_UNREACHABLE_CODE
+
int
main(int argc, char *argv[])
{
}
#endif
+RESTORE_WARNINGS
+
void
do_makedefs(char *options)
{
char bmpname[128];
FILE *fp;
+DISABLE_WARNING_UNREACHABLE_CODE
+
int
main(int argc, char *argv[])
{
return 0;
}
+RESTORE_WARNINGS
+
static void
build_bmfh(BITMAPFILEHEADER* pbmfh)
{
extern void objects_globals_init(void);
#endif
+DISABLE_WARNING_UNREACHABLE_CODE
+
int
main(int argc UNUSED, char *argv[] UNUSED)
{
return 0;
}
+RESTORE_WARNINGS
+
#endif /* TILETEXT */
struct {