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)
This commit is contained in:
nhmall
2022-11-24 00:51:42 -05:00
parent ddf1dfde29
commit 4b04b1e6ac
13 changed files with 173 additions and 19 deletions

View File

@@ -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)