[glib/atomic-older-cplusplus: 10/10] gmacros: Prioritize the usage of [[noreturn]] in C++11
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/atomic-older-cplusplus: 10/10] gmacros: Prioritize the usage of [[noreturn]] in C++11
- Date: Wed, 14 Sep 2022 01:39:29 +0000 (UTC)
commit 84f66a00e7823f94a2cd6da84e3f006160f6f294
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Wed Sep 14 01:59:24 2022 +0200
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).
glib/gmacros.h | 8 ++++----
glib/gmessages.h | 4 ++--
glib/gtestutils.h | 2 +-
glib/gutils.h | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/glib/gmacros.h b/glib/gmacros.h
index af117f48e6..f3fcd5e797 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -1047,16 +1047,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
diff --git a/glib/gmessages.h b/glib/gmessages.h
index 119b72e910..eab6d06784 100644
--- a/glib/gmessages.h
+++ b/glib/gmessages.h
@@ -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
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index bc404d96d9..5db453a70f 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -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,
diff --git a/glib/gutils.h b/glib/gutils.h
index d50ef709ec..d0e9c62631 100644
--- a/glib/gutils.h
+++ b/glib/gutils.h
@@ -439,8 +439,8 @@ 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]