mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-22 18:29:03 +01:00
tests: Ignore -Wdiscarded-qualifiers with volatile atomics tests
GCC 14 now emits this warning with the tests:
```
In file included from ../glib/gthread.h:34,
from ../glib/gasyncqueue.h:34,
from ../glib/glib.h:34,
from ../glib/tests/atomic.c:14:
../glib/tests/atomic.c: In function 'test_types':
../glib/gatomic.h:140:5: error: argument 2 of '__atomic_store' discards 'volatile' qualifier [-Werror=discarded-qualifiers]
140 | __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \
| ^~~~~~~~~~~~~~
../glib/tests/atomic.c:139:3: note: in expansion of macro 'g_atomic_pointer_set'
139 | g_atomic_pointer_set (&vp_str_vol, NULL);
| ^~~~~~~~~~~~~~~~~~~~
cc1.exe: all warnings being treated as errors
```
I can’t think of a way to cast around this in the definition of
`g_atomic_pointer_set()` without making the behaviour worse (less type
safe) for modern non-volatile atomic variables.
We would like to strongly nudge users of GLib away from declaring atomic
variables as `volatile`, so letting another compiler warning be emitted
when they do is not the end of the world. As long as it doesn’t stop old
code compiling (without `-Werror`).
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
@@ -136,6 +136,7 @@ test_types (void)
|
|||||||
* to make sure that we don’t warn when built against older third party code. */
|
* to make sure that we don’t warn when built against older third party code. */
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
|
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
|
||||||
|
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
|
||||||
g_atomic_pointer_set (&vp_str_vol, NULL);
|
g_atomic_pointer_set (&vp_str_vol, NULL);
|
||||||
g_atomic_pointer_set (&vp_str, str);
|
g_atomic_pointer_set (&vp_str, str);
|
||||||
res = g_atomic_pointer_compare_and_exchange (&vp_str_vol, NULL, str);
|
res = g_atomic_pointer_compare_and_exchange (&vp_str_vol, NULL, str);
|
||||||
|
|||||||
Reference in New Issue
Block a user