mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-31 08:16:17 +01:00
Merge branch 'gmacros-initialize-variable' into 'main'
gmacros: zero-initialize int G_PASTE (_g_boolean_var_, uniq) Closes #3582 See merge request GNOME/glib!4456
This commit is contained in:
commit
26bc1d08ec
@ -1239,11 +1239,9 @@
|
||||
#if G_GNUC_CHECK_VERSION(2, 0) && defined(__OPTIMIZE__)
|
||||
#define _G_BOOLEAN_EXPR_IMPL(uniq, expr) \
|
||||
G_GNUC_EXTENSION ({ \
|
||||
int G_PASTE (_g_boolean_var_, uniq); \
|
||||
int G_PASTE (_g_boolean_var_, uniq) = 0; \
|
||||
if (expr) \
|
||||
G_PASTE (_g_boolean_var_, uniq) = 1; \
|
||||
else \
|
||||
G_PASTE (_g_boolean_var_, uniq) = 0; \
|
||||
G_PASTE (_g_boolean_var_, uniq); \
|
||||
})
|
||||
#define _G_BOOLEAN_EXPR(expr) _G_BOOLEAN_EXPR_IMPL (__COUNTER__, expr)
|
||||
|
@ -536,6 +536,25 @@ test_string_free (void)
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
#if G_CXX_STD_CHECK_VERSION(14)
|
||||
static constexpr gboolean
|
||||
g_likely_test_expr (void)
|
||||
{
|
||||
if G_LIKELY (1 == 1)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_constexpr_var_init (void)
|
||||
{
|
||||
g_test_message ("Test that G_LIKELY macro creates an initialized variable "
|
||||
"for compatibility with constexpr");
|
||||
g_assert_true (g_likely_test_expr ());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
static void
|
||||
test_clear_com (void)
|
||||
@ -595,6 +614,10 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/C++/string-append", test_string_append);
|
||||
g_test_add_func ("/C++/string-free", test_string_free);
|
||||
|
||||
#if G_CXX_STD_CHECK_VERSION(14)
|
||||
g_test_add_func ("/C++/constexpr-var-init", test_constexpr_var_init);
|
||||
#endif
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
g_test_add_func ("/C++/test_clear_com", test_clear_com);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user