OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-link-grammar commits / b4f22e4

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.
b4f22e4f0f8f77c5eabbaf146be994d3b7526c97
by ampli <amirpli@gmail.com> · 2024-05-30T00:31:24.000Z

Changed files (3) +11 -7

link-grammar/error.h +3 -2
……@@ -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
9898extern void (* assert_failure_trap)(void);
9999#define FILELINE __FILE__ ":" STRINGIFY(__LINE__)
100NORETURN
100101void 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
……@@ -40,7 +40,7 @@ typedef uint8_t WordIdx_m; /* Storage representation of word index */
4040const bool ENABLE_WORD_SKIP_VECTOR = true;
4141const bool ENABLE_MATCH_LIST_CACHE = true;
4242const bool ENABLE_TABLE_LRCNT = true; // Also controls the above two caches.
43const bool USE_TABLE_TRACON = false; // The table is always maintained.
43const bool USE_TABLE_TRACON = true; // The table is always maintained.
4444const bool USE_PSEUDOCOUNT = true; // Controls only the non-cyclic solutions.
4545
4646typedef struct Table_tracon_s Table_tracon;
link-grammar/utilities.h +7 -4
……@@ -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,7 +280,7 @@ 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
……@@ -289,6 +288,10 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n)
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