mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 16:06:16 +01:00
Merge branch 'th/gtype-cast-align-warning' into 'main'
gtype: avoid "-Wcast-align" warning with optimized G_TYPE_CHECK_INSTANCE_CAST() See merge request GNOME/glib!3139
This commit is contained in:
commit
953f4fc25f
@ -2520,8 +2520,8 @@ const gchar * g_type_name_from_class (GTypeClass *g_class);
|
|||||||
|
|
||||||
/* --- implementation bits --- */
|
/* --- implementation bits --- */
|
||||||
#if defined(G_DISABLE_CAST_CHECKS) || defined(__OPTIMIZE__)
|
#if defined(G_DISABLE_CAST_CHECKS) || defined(__OPTIMIZE__)
|
||||||
# define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip)
|
# define _G_TYPE_CIC(ip, gt, ct) ((ct*) (void *) ip)
|
||||||
# define _G_TYPE_CCC(cp, gt, ct) ((ct*) cp)
|
# define _G_TYPE_CCC(cp, gt, ct) ((ct*) (void *) cp)
|
||||||
#else
|
#else
|
||||||
# define _G_TYPE_CIC(ip, gt, ct) \
|
# define _G_TYPE_CIC(ip, gt, ct) \
|
||||||
((ct*) (void *) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
|
((ct*) (void *) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
|
||||||
|
@ -76,7 +76,13 @@ gobject_tests = {
|
|||||||
'signalgroup' : {},
|
'signalgroup' : {},
|
||||||
'testing' : {},
|
'testing' : {},
|
||||||
'type-flags' : {},
|
'type-flags' : {},
|
||||||
'objects-refcount1' : {},
|
'objects-refcount1' : {
|
||||||
|
'c_args': cc.get_supported_arguments([
|
||||||
|
'-DG_DISABLE_CAST_CHECKS',
|
||||||
|
'-Werror',
|
||||||
|
'-Wcast-align=strict',
|
||||||
|
]),
|
||||||
|
},
|
||||||
'objects-refcount2' : {'suite' : ['slow']},
|
'objects-refcount2' : {'suite' : ['slow']},
|
||||||
'properties-refcount1' : {},
|
'properties-refcount1' : {},
|
||||||
'properties-refcount2' : {'suite' : ['slow']},
|
'properties-refcount2' : {'suite' : ['slow']},
|
||||||
|
@ -15,10 +15,27 @@
|
|||||||
typedef struct _GTest GTest;
|
typedef struct _GTest GTest;
|
||||||
typedef struct _GTestClass GTestClass;
|
typedef struct _GTestClass GTestClass;
|
||||||
|
|
||||||
|
#if G_GNUC_CHECK_VERSION (4, 0)
|
||||||
|
/* Increase the alignment of GTest to check whether
|
||||||
|
* G_TYPE_CHECK_INSTANCE_CAST() would trigger a "-Wcast-align=strict" warning.
|
||||||
|
* That would happen, when trying to cast a "GObject*" to "GTest*", if latter
|
||||||
|
* has larger alignment.
|
||||||
|
*
|
||||||
|
* Note that merely adding a int64 field to GTest does not increase the
|
||||||
|
* alignment above 4 bytes on i386, hence use the __attribute__((__aligned__())).
|
||||||
|
*/
|
||||||
|
#define _GTest_increase_alignment __attribute__((__aligned__(__alignof(gint64))))
|
||||||
|
#else
|
||||||
|
#define _GTest_increase_alignment
|
||||||
|
#endif
|
||||||
|
|
||||||
struct _GTest
|
struct _GTest
|
||||||
{
|
{
|
||||||
GObject object;
|
GObject object;
|
||||||
};
|
|
||||||
|
/* See _GTest_increase_alignment. */
|
||||||
|
long double increase_alignment2;
|
||||||
|
} _GTest_increase_alignment;
|
||||||
|
|
||||||
struct _GTestClass
|
struct _GTestClass
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user