Skip to content

Commit b4f22e4

Browse files
committed
Change GNUC_NORETURN to NORETURN and define for MSVC too
This prevents MSVC warnings after assert(0, ...) at end of functions that returns a value only at their middle.
1 parent 267dada commit b4f22e4

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

link-grammar/error.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "link-includes.h"
1717
#include "externs.h" // verbosity
18-
#include "utilities.h" // GNUC_NORETURN, STRINGIFY
18+
#include "utilities.h" // NORETURN, STRINGIFY
1919

2020
/* User verbosity levels are 1-4, to be used for user info/debug.
2121
* For now hard-coded numbers are still used instead of D_USER_BASIC/TIMES. */
@@ -97,8 +97,9 @@ void lg_lib_failure(void);
9797

9898
extern void (* assert_failure_trap)(void);
9999
#define FILELINE __FILE__ ":" STRINGIFY(__LINE__)
100+
NORETURN
100101
void assert_failure(const char[], const char[], const char *, const char *, ...)
101-
GNUC_PRINTF(4,5) GNUC_NORETURN;
102+
GNUC_PRINTF(4,5);
102103

103104
/* Define a private version of assert() with a printf-like error
104105
* message. The C one is not used. */

link-grammar/parse/count.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef uint8_t WordIdx_m; /* Storage representation of word index */
4040
const bool ENABLE_WORD_SKIP_VECTOR = true;
4141
const bool ENABLE_MATCH_LIST_CACHE = true;
4242
const bool ENABLE_TABLE_LRCNT = true; // Also controls the above two caches.
43-
const bool USE_TABLE_TRACON = false; // The table is always maintained.
43+
const bool USE_TABLE_TRACON = true; // The table is always maintained.
4444
const bool USE_PSEUDOCOUNT = true; // Controls only the non-cyclic solutions.
4545

4646
typedef struct Table_tracon_s Table_tracon;

link-grammar/utilities.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,13 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n)
253253
* support C11. So it already supports all the features below. */
254254

255255
/* Optimizations etc. that only gcc understands */
256-
/* FIXME: Change to ATTR_* and define also for MSVC. */
256+
/* FIXME: Define also for MSVC. */
257257
#if __GNUC__
258258
#define GCC_DIAGNOSTIC
259259
#define UNREACHABLE(x) (__extension__ ({if (x) __builtin_unreachable();}))
260260
#define GNUC_MALLOC __attribute__ ((__malloc__))
261261
#define GNUC_UNUSED __attribute__ ((__unused__))
262-
#define GNUC_NORETURN __attribute__ ((__noreturn__))
262+
#define NORETURN __attribute__ ((__noreturn__))
263263
#define ATTR_PURE __attribute__ ((__pure__))
264264
#define NO_SAN __attribute__ ((no_sanitize_address, no_sanitize_undefined))
265265

@@ -271,7 +271,6 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n)
271271
#else
272272
#define NO_SAN_DICT
273273
#endif
274-
275274
#ifndef DONT_EXPECT
276275
#define likely(x) __builtin_expect(!!(x), 1)
277276
#define unlikely(x) __builtin_expect(!!(x), 0)
@@ -281,14 +280,18 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n)
281280
#define UNREACHABLE(x)
282281
#define GNUC_MALLOC
283282
#define GNUC_UNUSED
284-
#define GNUC_NORETURN
283+
#define NORETURN
285284
#define ATTR_PURE
286285
#define NO_SAN_DICT
287286

288287
#define likely(x) x
289288
#define unlikely(x) x
290289
#endif
291290

291+
#ifdef _MSC_VER
292+
#undef NORETURN
293+
#define NORETURN __declspec(noreturn)
294+
#endif
292295

293296
/* Apply a pragma to a specific code section only.
294297
* XXX According to the GCC docs, we cannot use here something like

0 commit comments

Comments
 (0)