From 4b04b1e6ac59b9fbb6dbabae4017b855896c3661 Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 24 Nov 2022 00:51:42 -0500 Subject: [PATCH] expand support for noreturn declarations Although gcc specifies support for declaring a function as noreturn after the function name and parameters, other compilers do so via an attribute at the start of the declaration. Add some macro support for the attribute-at-the-beginning method: o MS Visual Studio compiler o Upcoming C23 standard (untested at this point) --- include/extern.h | 16 ++++++++-------- include/tradstdc.h | 25 +++++++++++++++++++++++++ src/dungeon.c | 17 +++++++++++++++++ src/end.c | 4 ++-- src/mondata.c | 5 +++++ src/nhlobj.c | 17 +++++++++++++++++ src/nhlsel.c | 5 +++++ src/nhlua.c | 40 +++++++++++++++++++++++++++++++++++----- src/sp_lev.c | 37 +++++++++++++++++++++++++++++++++++++ src/timeout.c | 6 ++++++ sys/vms/vmsmisc.c | 8 ++++---- sys/windows/windmain.c | 8 ++++++++ win/tty/wintty.c | 4 ++++ 13 files changed, 173 insertions(+), 19 deletions(-) diff --git a/include/extern.h b/include/extern.h index 830a64e03..ff5301b77 100644 --- a/include/extern.h +++ b/include/extern.h @@ -784,12 +784,12 @@ extern void done_in_by(struct monst *, int); extern void done_object_cleanup(void); #endif /* !MAKEDEFS_C && MDLIB_C && !CPPREGEX_C */ #if !defined(CPPREGEX_C) -extern void panic(const char *, ...) PRINTF_F(1, 2) NORETURN; +ATTRNORETURN extern void panic(const char *, ...) PRINTF_F(1, 2) NORETURN; #endif #if !defined(MAKEDEFS_C) && !defined(MDLIB_C) && !defined(CPPREGEX_C) extern void done(int); extern void container_contents(struct obj *, boolean, boolean, boolean); -extern void nh_terminate(int) NORETURN; +ATTRNORETURN extern void nh_terminate(int) NORETURN; extern void delayed_killer(int, int, const char *); extern struct kinfo *find_delayed_killer(int); extern void dealloc_killer(struct kinfo *); @@ -1830,7 +1830,7 @@ extern void nhl_done(lua_State *); extern boolean nhl_loadlua(lua_State *, const char *); extern int nhl_pcall(lua_State *, int, int); extern boolean load_lua(const char *, nhl_sandbox_info *); -extern void nhl_error(lua_State *, const char *) NORETURN; +ATTRNORETURN extern void nhl_error(lua_State *, const char *) NORETURN; extern void lcheck_param_table(lua_State *); extern schar get_table_mapchr(lua_State *, const char *); extern schar get_table_mapchr_opt(lua_State *, const char *, schar); @@ -2072,7 +2072,7 @@ extern void msmsg(const char *, ...) PRINTF_F(1, 2); extern void gettty(void); extern void settty(const char *); extern void setftty(void); -extern void error(const char *, ...) PRINTF_F(1, 2) NORETURN; +ATTRNORETURN extern void error(const char *, ...) PRINTF_F(1, 2) NORETURN; #if defined(TIMED_DELAY) && defined(_MSC_VER) extern void msleep(unsigned); #endif @@ -3000,7 +3000,7 @@ extern void settty(const char *); extern void setftty(void); extern void intron(void); extern void introff(void); -extern void error (const char *, ...) PRINTF_F(1, 2) NORETURN; +ATTRNORETURN extern void error(const char *, ...) PRINTF_F(1, 2) NORETURN; #ifdef ENHANCED_SYMBOLS extern void tty_utf8graphics_fixup(void); #endif @@ -3152,8 +3152,8 @@ extern boolean authorize_wizard_mode(void); /* ### vmsmisc.c ### */ -extern void vms_abort(void) NORETURN; -extern void vms_exit(int) NORETURN; +ATTRNORETURN extern void vms_abort(void) NORETURN; +ATTRNORETURN extern void vms_exit(int) NORETURN; #ifdef PANICTRACE extern void vms_traceback(int); #endif @@ -3167,7 +3167,7 @@ extern void shuttty(const char *); extern void setftty(void); extern void intron(void); extern void introff(void); -extern void error (const char *, ...) PRINTF_F(1, 2) NORETURN; +ATTRNORETURN extern void error (const char *, ...) PRINTF_F(1, 2) NORETURN; #ifdef TIMED_DELAY extern void msleep(unsigned); #endif diff --git a/include/tradstdc.h b/include/tradstdc.h index 3681861aa..a5f53fe8d 100644 --- a/include/tradstdc.h +++ b/include/tradstdc.h @@ -393,6 +393,17 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ #endif #endif +/* + * Give first priority to standard + */ +#ifndef ATTRNORETURN +#if defined(__STDC_VERSION__) || defined(__cplusplus) +#if (__STDC_VERSION__ > 202300L) || defined(__cplusplus) +#define ATTRNORETURN [[noreturn]] +#endif +#endif +#endif + /* * Allow gcc2 to check parameters of printf-like calls with -Wformat; * append this to a prototype declaration (see pline() in extern.h). @@ -406,7 +417,11 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ #endif #if __GNUC__ >= 3 #define UNUSED __attribute__((unused)) +#ifndef ATTRNORETURN +#ifndef NORETURN #define NORETURN __attribute__((noreturn)) +#endif +#endif #if (!defined(__linux__) && !defined(MACOS)) || defined(GCC_URWARN) /* disable gcc's __attribute__((__warn_unused_result__)) since explicitly discarding the result by casting to (void) is not accepted as a 'use' */ @@ -419,6 +434,12 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ #endif #endif +#ifdef _MSC_VER +#ifndef ATTRNORETURN +#define ATTRNORETURN __declspec(noreturn) +#endif +#endif + #ifndef PRINTF_F #define PRINTF_F(f, v) #endif @@ -428,6 +449,9 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ #ifndef UNUSED #define UNUSED #endif +#ifndef ATTRNORETURN +#define ATTRNORETURN +#endif #ifndef NORETURN #define NORETURN #endif @@ -435,4 +459,5 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ #define NONNULL #endif + #endif /* TRADSTDC_H */ diff --git a/src/dungeon.c b/src/dungeon.c index 2d108f8ec..31e944815 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -264,6 +264,8 @@ Fread(genericptr_t ptr, int size, int nitems, dlb *stream) } #endif +DISABLE_WARNING_UNREACHABLE_CODE + static xint16 dname_to_dnum(const char *s) { @@ -278,6 +280,8 @@ dname_to_dnum(const char *s) return (xint16) 0; } +RESTORE_WARNING_UNREACHABLE_CODE + s_level * find_level(const char *s) { @@ -317,6 +321,8 @@ find_branch(const char *s, /* dungeon name */ return i; } +DISABLE_WARNING_UNREACHABLE_CODE + /* * Find the "parent" by searching the prototype branch list for the branch * listing, then figuring out to which dungeon it belongs. @@ -342,6 +348,8 @@ parent_dnum(const char *s, /* dungeon name */ return (xint16) 0; } +RESTORE_WARNING_UNREACHABLE_CODE + /* * Return a starting point and number of successive positions a level * or dungeon entrance can occupy. @@ -592,6 +600,8 @@ possible_places(int idx, /* prototype index */ return count; } +DISABLE_WARNING_UNREACHABLE_CODE + /* Pick the nth TRUE entry in the given boolean array. */ static xint16 pick_level(boolean *map, /* an array MAXLEVEL+1 in size */ @@ -602,9 +612,12 @@ pick_level(boolean *map, /* an array MAXLEVEL+1 in size */ if (map[i] && !nth--) return i; panic("pick_level: ran out of valid levels"); + /*NOTREACHED*/ return 0; } +RESTORE_WARNING_UNREACHABLE_CODE + #ifdef DDEBUG static void indent(int); @@ -1271,6 +1284,8 @@ maxledgerno(void) + g.dungeons[g.n_dgns - 1].num_dunlevs); } +DISABLE_WARNING_UNREACHABLE_CODE + /* return the dungeon that this ledgerno exists in */ xint16 ledger_to_dnum(xint16 ledgerno) @@ -1289,6 +1304,8 @@ ledger_to_dnum(xint16 ledgerno) return (xint16) 0; } +RESTORE_WARNING_UNREACHABLE_CODE + /* return the level of the dungeon this ledgerno exists in */ xint16 ledger_to_dlev(xint16 ledgerno) diff --git a/src/end.c b/src/end.c index 9dbc47133..e97a7b2e1 100644 --- a/src/end.c +++ b/src/end.c @@ -596,7 +596,7 @@ fixup_death(int how) DISABLE_WARNING_FORMAT_NONLITERAL /*VARARGS1*/ -void +ATTRNORETURN void panic VA_DECL(const char *, str) { VA_START(str); @@ -1780,7 +1780,7 @@ container_contents( } /* should be called with either EXIT_SUCCESS or EXIT_FAILURE */ -void +ATTRNORETURN void nh_terminate(int status) { g.program_state.in_moveloop = 0; /* won't be returning to normal play */ diff --git a/src/mondata.c b/src/mondata.c index 4b5a03fdc..02db06674 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -765,6 +765,8 @@ same_race(struct permonst* pm1, struct permonst* pm2) return FALSE; } +DISABLE_WARNING_UNREACHABLE_CODE + /* return an index into the mons array */ int monsndx(struct permonst* ptr) @@ -775,11 +777,14 @@ monsndx(struct permonst* ptr) if (i < LOW_PM || i >= NUMMONS) { panic("monsndx - could not index monster (%s)", fmt_ptr((genericptr_t) ptr)); + /*NOTREACHED*/ return NON_PM; /* will not get here */ } return i; } +RESTORE_WARNING_UNREACHABLE_CODE + /* for handling alternate spellings */ struct alt_spl { const char *name; diff --git a/src/nhlobj.c b/src/nhlobj.c index 32c8b02d2..8356255b3 100644 --- a/src/nhlobj.c +++ b/src/nhlobj.c @@ -158,6 +158,8 @@ nhl_obj_u_giveobj(lua_State *L) return 0; } +DISABLE_WARNING_UNREACHABLE_CODE + /* Get a table of object class data. */ /* local odata = obj.class(otbl.otyp); */ /* local odata = obj.class(obj.new("rock")); */ @@ -171,6 +173,7 @@ l_obj_objects_to_table(lua_State *L) if (argc != 1) { nhl_error(L, "l_obj_objects_to_table: Wrong args"); + /*NOTREACHED*/ return 0; } @@ -230,6 +233,8 @@ l_obj_objects_to_table(lua_State *L) return 1; } +RESTORE_WARNING_UNREACHABLE_CODE + /* Create a lua table representation of the object, unpacking all the object fields. local o = obj.new("rock"); @@ -331,6 +336,8 @@ l_obj_to_table(lua_State *L) return 1; } +DISABLE_WARNING_UNREACHABLE_CODE + /* create a new object via wishing routine */ /* local o = obj.new("rock"); */ static int @@ -348,6 +355,7 @@ l_obj_new_readobjnam(lua_State *L) return 1; } else nhl_error(L, "l_obj_new_readobjname: Wrong args"); + /*NOTREACHED*/ return 0; } @@ -370,6 +378,7 @@ l_obj_at(lua_State *L) return 1; } else nhl_error(L, "l_obj_at: Wrong args"); + /*NOTREACHED*/ return 0; } @@ -401,6 +410,8 @@ l_obj_placeobj(lua_State *L) return 0; } +RESTORE_WARNING_UNREACHABLE_CODE + /* Get the next object in the object chain */ /* local o = obj.at(x, y); local o2 = o:next(true); @@ -453,6 +464,8 @@ l_obj_isnull(lua_State *L) return 1; } +DISABLE_WARNING_UNREACHABLE_CODE + /* does object have a timer of certain type? */ /* local hastimer = o:has_timer("rot-organic"); */ static int @@ -476,6 +489,7 @@ l_obj_timer_has(lua_State *L) return 0; } + /* peek at an object timer. return the turn when timer triggers. returns 0 if no such timer attached to the object. */ /* local timeout = o:peek_timer("hatch-egg"); */ @@ -497,6 +511,7 @@ l_obj_timer_peek(lua_State *L) } } else nhl_error(L, "l_obj_timer_peek: Wrong args"); + /*NOTREACHED*/ return 0; } @@ -533,6 +548,8 @@ l_obj_timer_stop(lua_State *L) return 0; } +RESTORE_WARNING_UNREACHABLE_CODE + /* start an object timer. */ /* o:start_timer("hatch-egg", 10); */ static int diff --git a/src/nhlsel.c b/src/nhlsel.c index 96ed226d2..6aa2963ad 100644 --- a/src/nhlsel.c +++ b/src/nhlsel.c @@ -145,6 +145,8 @@ l_selection_clone(lua_State *L) return 1; } +DISABLE_WARNING_UNREACHABLE_CODE + /* selection.set(sel, x, y); */ /* selection.set(sel, x, y, value); */ /* local sel = selection.set(); */ @@ -207,6 +209,7 @@ l_selection_getpoint(lua_State *L) lua_remove(L, 1); /* sel */ if (!nhl_get_xy_params(L, &ix, &iy)) { nhl_error(L, "l_selection_getpoint: Incorrect params"); + /*NOTREACHED*/ return 0; } x = (coordxy) ix; @@ -224,6 +227,8 @@ l_selection_getpoint(lua_State *L) return 1; } +RESTORE_WARNING_UNREACHABLE_CODE + /* local s = selection.negate(sel); */ /* local s = selection.negate(); */ /* local s = sel:negate(); */ diff --git a/src/nhlua.c b/src/nhlua.c index 77c1d8980..f0ab64859 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -168,7 +168,7 @@ l_nhcore_call(int callidx) DISABLE_WARNING_UNREACHABLE_CODE -void +ATTRNORETURN void nhl_error(lua_State *L, const char *msg) { lua_Debug ar; @@ -188,7 +188,6 @@ nhl_error(lua_State *L, const char *msg) #endif (void) lua_error(L); /*NOTREACHED*/ - /* UNREACHABLE_CODE */ } RESTORE_WARNING_UNREACHABLE_CODE @@ -209,6 +208,8 @@ lcheck_param_table(lua_State *L) luaL_checktype(L, 1, LUA_TTABLE); } +DISABLE_WARNING_UNREACHABLE_CODE + schar get_table_mapchr(lua_State *L, const char *name) { @@ -257,6 +258,8 @@ nhl_get_timertype(lua_State *L, int idx) return ret; } +RESTORE_WARNING_UNREACHABLE_CODE + void nhl_add_table_entry_int(lua_State *L, const char *name, lua_Integer value) { @@ -375,6 +378,8 @@ splev_typ2chr(schar typ) return 'x'; } +DISABLE_WARNING_UNREACHABLE_CODE + /* local t = nh.gettrap(x,y); */ /* local t = nh.gettrap({ x = 10, y = 10 }); */ static int @@ -385,6 +390,7 @@ nhl_gettrap(lua_State *L) if (!nhl_get_xy_params(L, &lx, &ly)) { nhl_error(L, "Incorrect arguments"); + /*NOTREACHED*/ return 0; } x = (coordxy) lx; @@ -436,6 +442,7 @@ nhl_deltrap(lua_State *L) if (!nhl_get_xy_params(L, &lx, &ly)) { nhl_error(L, "Incorrect arguments"); + /*NOTREACHED*/ return 0; } x = (coordxy) lx; @@ -451,6 +458,8 @@ nhl_deltrap(lua_State *L) return 0; } +RESTORE_WARNING_UNREACHABLE_CODE + /* get parameters (XX,YY) or ({ x = XX, y = YY }) or ({ XX, YY }), and set the x and y values. return TRUE if there are such params in the stack. @@ -574,8 +583,6 @@ nhl_getmap(lua_State *L) } } -RESTORE_WARNING_CONDEXPR_IS_CONSTANT - /* impossible("Error!") */ static int nhl_impossible(lua_State *L) @@ -664,6 +671,7 @@ nhl_getlin(lua_State *L) } nhl_error(L, "Wrong args"); + /*NOTREACHED*/ return 0; } @@ -688,6 +696,7 @@ nhl_menu(lua_State *L) if (argc < 2 || argc > 4) { nhl_error(L, "Wrong args"); + /*NOTREACHED*/ return 0; } @@ -874,6 +883,8 @@ nhl_level_difficulty(lua_State *L) return 1; } +RESTORE_WARNING_UNREACHABLE_CODE + /* get mandatory integer value from table */ int get_table_int(lua_State *L, const char *name) @@ -1150,6 +1161,8 @@ nhl_debug_flags(lua_State *L) return 0; } +DISABLE_WARNING_UNREACHABLE_CODE + /* does location at x,y have timer? */ /* local has_melttimer = nh.has_timer_at(x,y, "melt-ice"); */ /* local has_melttimer = nh.has_timer_at({x=4,y=7}, "melt-ice"); */ @@ -1165,6 +1178,7 @@ nhl_timer_has_at(lua_State *L) lua_pop(L, 1); /* remove timertype */ if (!nhl_get_xy_params(L, &lx, &ly)) { nhl_error(L, "nhl_timer_has_at: Wrong args"); + /*NOTREACHED*/ return 0; } @@ -1194,6 +1208,7 @@ nhl_timer_peek_at(lua_State *L) lua_pop(L, 1); /* remove timertype */ if (!nhl_get_xy_params(L, &lx, &ly)) { nhl_error(L, "nhl_timer_peek_at: Wrong args"); + /*NOTREACHED*/ return 0; } @@ -1220,6 +1235,7 @@ nhl_timer_stop_at(lua_State *L) lua_pop(L, 1); /* remove timertype */ if (!nhl_get_xy_params(L, &lx, &ly)) { nhl_error(L, "nhl_timer_stop_at: Wrong args"); + /*NOTREACHED*/ return 0; } @@ -1245,6 +1261,7 @@ nhl_timer_start_at(lua_State *L) lua_pop(L, 2); /* remove when and timertype */ if (!nhl_get_xy_params(L, &lx, &ly)) { nhl_error(L, "nhl_timer_start_at: Wrong args"); + /*NOTREACHED*/ return 0; } @@ -1262,6 +1279,8 @@ nhl_timer_start_at(lua_State *L) return 0; } +RESTORE_WARNING_UNREACHABLE_CODE + static const struct luaL_Reg nhl_functions[] = { {"test", nhl_test}, @@ -1357,6 +1376,8 @@ nhl_push_anything(lua_State *L, int anytype, void *src) return 1; } +DISABLE_WARNING_UNREACHABLE_CODE + static int nhl_meta_u_index(lua_State *L) { @@ -1417,6 +1438,7 @@ nhl_meta_u_index(lua_State *L) } nhl_error(L, "Unknown u table index"); + /*NOTREACHED*/ return 0; } @@ -1424,9 +1446,12 @@ static int nhl_meta_u_newindex(lua_State *L) { nhl_error(L, "Cannot set u table values"); + /*NOTREACHED*/ return 0; } +RESTORE_WARNING_UNREACHABLE_CODE + static int nhl_u_clear_inventory(lua_State *L UNUSED) { @@ -1790,7 +1815,7 @@ get_lua_version(void) return (const char *) g.lua_ver; } -RESTORE_WARNINGS +RESTORE_WARNING_CONDEXPR_IS_CONSTANT /*** *** SANDBOX / HARDENING CODE @@ -2297,6 +2322,8 @@ nhl_alloc(void *ud, void *ptr, size_t osize, size_t nsize) return re_alloc(ptr, nsize); } +DISABLE_WARNING_UNREACHABLE_CODE + static int nhl_panic(lua_State *L) { @@ -2305,9 +2332,12 @@ nhl_panic(lua_State *L) if (msg == NULL) msg = "error object is not a string"; panic("unprotected error in call to Lua API (%s)\n", msg); + /*NOTREACHED*/ return 0; /* return to Lua to abort */ } +RESTORE_WARNING_UNREACHABLE_CODE + /* called when lua issues a warning message; the text of the message is passed to us in pieces across multiple function calls */ static void diff --git a/src/sp_lev.c b/src/sp_lev.c index 142ad63f6..5297cd7fa 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -2988,6 +2988,8 @@ l_push_mkroom_table(lua_State *L, struct mkroom *tmpr) nhl_add_table_entry_str(L, "type", get_mkroom_name(tmpr->rtype)); } +DISABLE_WARNING_UNREACHABLE_CODE + /* message("What a strange feeling!"); */ int lspo_message(lua_State *L) @@ -3000,6 +3002,7 @@ lspo_message(lua_State *L) if (argc < 1) { nhl_error(L, "Wrong parameters"); + /*NOTREACHED*/ return 0; } @@ -3024,6 +3027,8 @@ lspo_message(lua_State *L) return 0; /* number of results */ } +RESTORE_WARNING_UNREACHABLE_CODE + static int get_table_align(lua_State *L) { @@ -3295,6 +3300,8 @@ lspo_monster(lua_State *L) return 0; } +DISABLE_WARNING_UNREACHABLE_CODE + /* the hash key 'name' is an integer or "random", or if not existent, also return rndval */ static lua_Integer @@ -3321,6 +3328,7 @@ get_table_int_or_random(lua_State *L, const char *name, int rndval) else Strcat(buf, ""); nhl_error(L, buf); + /*NOTREACHED*/ lua_pop(L, 1); return 0; } @@ -3329,6 +3337,8 @@ get_table_int_or_random(lua_State *L, const char *name, int rndval) return ret; } +RESTORE_WARNING_UNREACHABLE_CODE + static int get_table_buc(lua_State *L) { @@ -4300,6 +4310,8 @@ lspo_trap(lua_State *L) return 0; } +DISABLE_WARNING_UNREACHABLE_CODE + /* gold(500, 3,5); */ /* gold(500, {5, 6}); */ /* gold({ amount = 500, x = 2, y = 5 });*/ @@ -4333,6 +4345,7 @@ lspo_gold(lua_State *L) x = gx, y = gy; } else { nhl_error(L, "Wrong parameters"); + /*NOTREACHED*/ return 0; } @@ -4349,6 +4362,8 @@ lspo_gold(lua_State *L) return 0; } +RESTORE_WARNING_UNREACHABLE_CODE + /* corridor({ srcroom=1, srcdoor=2, srcwall="north", destroom=2, destdoor=1, destwall="west" });*/ int lspo_corridor(lua_State *L) @@ -5312,6 +5327,8 @@ cvt_to_relcoord(coordxy *x, coordxy *y) } } +DISABLE_WARNING_UNREACHABLE_CODE + /* convert map-relative coordinate to absolute. local ax,ay = nh.abscoord(rx, ry); local pt = nh.abscoord({ x = 10, y = 5 }); @@ -5339,6 +5356,7 @@ nhl_abs_coord(lua_State *L) return 1; } else { nhl_error(L, "nhl_abs_coord: Wrong args"); + /*NOTREACHED*/ return 0; } } @@ -5417,6 +5435,8 @@ lspo_feature(lua_State *L) return 0; } +RESTORE_WARNING_UNREACHABLE_CODE + /* * [lit_state: 1 On, 0 Off, -1 random, -2 leave as-is] * terrain({ x=NN, y=NN, typ=MAPCHAR, lit=lit_state }); @@ -5701,6 +5721,8 @@ ensure_way_out(void) selection_free(ov, TRUE); } +DISABLE_WARNING_UNREACHABLE_CODE + static lua_Integer get_table_intarray_entry(lua_State *L, int tableidx, int entrynum) { @@ -5746,6 +5768,7 @@ get_table_region( lua_pop(L, 1); if (arrlen != 4) { nhl_error(L, "Not a region"); + /*NOTREACHED*/ lua_pop(L, 1); return 0; } @@ -5784,6 +5807,7 @@ get_coord(lua_State *L, int i, lua_Integer *x, lua_Integer *y) ret = TRUE; } else { nhl_error(L, "Not a coordinate"); + /*NOTREACHED*/ return FALSE; } } else { @@ -5792,6 +5816,7 @@ get_coord(lua_State *L, int i, lua_Integer *x, lua_Integer *y) lua_pop(L, 1); if (arrlen != 2) { nhl_error(L, "Not a coordinate"); + /*NOTREACHED*/ return FALSE; } @@ -5807,6 +5832,8 @@ get_coord(lua_State *L, int i, lua_Integer *x, lua_Integer *y) return ret; } +RESTORE_WARNING_UNREACHABLE_CODE + static void levregion_add(lev_region* lregion) { @@ -5944,6 +5971,8 @@ add_doors_to_room(struct mkroom *croom) maybe_add_door(x, y, croom); } +DISABLE_WARNING_UNREACHABLE_CODE + /* region(selection, lit); */ /* region({ x1=NN, y1=NN, x2=NN, y2=NN, lit=BOOL, type=ROOMTYPE, joined=BOOL, irregular=BOOL, filled=NN [ , contents = FUNCTION ] }); */ @@ -6005,6 +6034,7 @@ lspo_region(lua_State *L) return 0; } else { nhl_error(L, "Wrong parameters"); + /*NOTREACHED*/ return 0; } @@ -6087,6 +6117,8 @@ lspo_region(lua_State *L) return 0; } +RESTORE_WARNING_UNREACHABLE_CODE + /* drawbridge({ dir="east", state="closed", x=05,y=08 }); */ /* drawbridge({ dir="east", state="closed", coord={05,08} }); */ int @@ -6427,6 +6459,8 @@ lspo_finalize_level(lua_State *L UNUSED) return 0; } +DISABLE_WARNING_UNREACHABLE_CODE + /* map({ x = 10, y = 10, map = [[...]] }); */ /* map({ coord = {10, 10}, map = [[...]] }); */ /* map({ halign = "center", valign = "center", map = [[...]] }); */ @@ -6489,6 +6523,7 @@ TODO: g.coder->croom needs to be updated if (!mf) { nhl_error(L, "Map data error"); + /*NOTREACHED*/ return 0; } @@ -6682,6 +6717,8 @@ TODO: g.coder->croom needs to be updated return 0; } +RESTORE_WARNING_UNREACHABLE_CODE + struct selectionvar * selection_from_mkroom(struct mkroom *croom) { diff --git a/src/timeout.c b/src/timeout.c index 0fb8d5d1f..6c57d9e6d 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -2316,6 +2316,8 @@ write_timer(NHFILE* nhfp, timer_element* timer) } } +DISABLE_WARNING_UNREACHABLE_CODE + /* * Return TRUE if the object will stay on the level when the level is * saved. @@ -2336,6 +2338,7 @@ obj_is_local(struct obj* obj) return mon_is_local(obj->ocarry); } panic("obj_is_local"); + /*NOTREACHED*/ return FALSE; } @@ -2376,9 +2379,12 @@ timer_is_local(timer_element* timer) return mon_is_local(timer->arg.a_monst); } panic("timer_is_local"); + /*NOTREACHED*/ return FALSE; } +RESTORE_WARNING_UNREACHABLE_CODE + /* * Part of the save routine. Count up the number of timers that would * be written. If write_it is true, actually write the timer. diff --git a/sys/vms/vmsmisc.c b/sys/vms/vmsmisc.c index 2cfbfe359..e0f195ad4 100644 --- a/sys/vms/vmsmisc.c +++ b/sys/vms/vmsmisc.c @@ -9,14 +9,14 @@ int debuggable = 0; /* 1 if we can debug or show a call trace */ -void vms_exit(int); -void vms_abort(void); +ATTRNORETURN void vms_exit(int); +ATTRNORETURN void vms_abort(void); /* first arg should be unsigned long but has unsigned int */ extern void VDECL(lib$signal, (unsigned, ...)); /* terminate, converting Unix-style exit code into VMS status code */ -void +ATTRNORETURN void vms_exit(int status) { /* convert non-zero to failure, zero to success */ @@ -25,7 +25,7 @@ vms_exit(int status) } /* put the user into the debugger; used for abort() when in wizard mode */ -void +ATTRNORETURN void vms_abort(void) { if (debuggable) diff --git a/sys/windows/windmain.c b/sys/windows/windmain.c index e42d7aa65..2d7d6eeee 100644 --- a/sys/windows/windmain.c +++ b/sys/windows/windmain.c @@ -89,6 +89,8 @@ static struct stat hbuf; extern char orgdir[]; +DISABLE_WARNING_UNREACHABLE_CODE + int get_known_folder_path( const KNOWNFOLDERID * folder_id, @@ -128,6 +130,8 @@ create_directory(const char * path) error("Unable to create directory '%s'", path); } +RESTORE_WARNING_UNREACHABLE_CODE + int build_known_folder_path( const KNOWNFOLDERID * folder_id, @@ -1149,6 +1153,8 @@ eraseoldlocks(void) return (1); /* success! */ } +DISABLE_WARNING_UNREACHABLE_CODE + int getlock(void) { @@ -1288,6 +1294,8 @@ file_exists(const char* path) return TRUE; } +RESTORE_WARNING_UNREACHABLE_CODE + /* file_newer returns TRUE if the file at a_path is newer then the file at b_path. If a_path does not exist, it returns FALSE. If b_path diff --git a/win/tty/wintty.c b/win/tty/wintty.c index a05db43ad..d2bb28f20 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1537,6 +1537,8 @@ tty_exit_nhwindows(const char *str) iflags.window_inited = 0; } +DISABLE_WARNING_UNREACHABLE_CODE + winid tty_create_nhwindow(int type) { @@ -1651,6 +1653,8 @@ tty_create_nhwindow(int type) return newid; } +RESTORE_WARNING_UNREACHABLE_CODE + static void erase_menu_or_text(winid window, struct WinDesc *cw, boolean clear) {