mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +01:00
gmacros: Prioritize the usage of [[noreturn]] in C++11
We defined G_NO_RETURN as [[noreturn]] in the C++ case, but only after trying the __attribute__ syntax, so it was never used in GNUC compatible compilers. Give it priority instead when supporting a C++11 compiler and onwards. As per this we need to adapt the code in the places where it was not properly used (leading to compilation warnings).
This commit is contained in:
parent
372ab7a964
commit
641256ea22
@ -1053,16 +1053,16 @@
|
||||
* evaluated when a header is included. This results in warnings in third party
|
||||
* code which includes glib.h, even if the third party code doesn’t use the new
|
||||
* macro itself. */
|
||||
#if g_macro__has_attribute(__noreturn__)
|
||||
#if G_CXX_STD_CHECK_VERSION (11)
|
||||
/* Use ISO C++11 syntax when the compiler supports it. */
|
||||
# define G_NORETURN [[noreturn]]
|
||||
#elif g_macro__has_attribute(__noreturn__)
|
||||
/* For compatibility with G_NORETURN_FUNCPTR on clang, use
|
||||
__attribute__((__noreturn__)), not _Noreturn. */
|
||||
# define G_NORETURN __attribute__ ((__noreturn__))
|
||||
#elif defined (_MSC_VER) && (1200 <= _MSC_VER)
|
||||
/* Use MSVC specific syntax. */
|
||||
# define G_NORETURN __declspec (noreturn)
|
||||
/* Use ISO C++11 syntax when the compiler supports it. */
|
||||
#elif G_CXX_STD_CHECK_VERSION (11)
|
||||
# define G_NORETURN [[noreturn]]
|
||||
/* Use ISO C11 syntax when the compiler supports it. */
|
||||
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112
|
||||
# define G_NORETURN _Noreturn
|
||||
|
@ -291,8 +291,8 @@ void g_warn_message (const char *domain,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *warnexpr) G_ANALYZER_NORETURN;
|
||||
GLIB_DEPRECATED
|
||||
G_NORETURN
|
||||
GLIB_DEPRECATED
|
||||
void g_assert_warning (const char *log_domain,
|
||||
const char *file,
|
||||
const int line,
|
||||
@ -409,7 +409,7 @@ void g_log_structured_standard (const gchar *log_domain,
|
||||
format)
|
||||
#endif
|
||||
#else /* no varargs macros */
|
||||
static G_NORETURN void g_error (const gchar *format, ...) G_ANALYZER_NORETURN;
|
||||
G_NORETURN static void g_error (const gchar *format, ...) G_ANALYZER_NORETURN;
|
||||
static void g_critical (const gchar *format, ...) G_ANALYZER_NORETURN;
|
||||
|
||||
static inline void
|
||||
|
@ -541,8 +541,8 @@ void g_assertion_message (const char *domain,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *message) G_ANALYZER_NORETURN;
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
G_NORETURN
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
void g_assertion_message_expr (const char *domain,
|
||||
const char *file,
|
||||
int line,
|
||||
|
@ -426,8 +426,7 @@ g_bit_storage_impl (gulong number)
|
||||
# include <stdlib.h>
|
||||
# define g_abort() abort ()
|
||||
#else
|
||||
GLIB_AVAILABLE_IN_2_50
|
||||
G_NORETURN void g_abort (void) G_ANALYZER_NORETURN;
|
||||
G_NORETURN GLIB_AVAILABLE_IN_2_50 void g_abort (void) G_ANALYZER_NORETURN;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user