[glib/c-cxx-std-versions: 4/7] gmacros: Prioritize the usage of [[noreturn]] in C++11




commit 3a838bf1101d910e70592880883386bde91955dc
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     | 3 +--
 4 files changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/glib/gmacros.h b/glib/gmacros.h
index 6b64747ecc..4c9ffbc4c6 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -1050,16 +1050,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..bb8aec56ed 100644
--- a/glib/gutils.h
+++ b/glib/gutils.h
@@ -439,8 +439,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
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]