From 1aa75d411dd68f6e015a747a39b5179cb5573bb8 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Tue, 11 Feb 2020 00:23:29 -0500 Subject: [PATCH] Make --no-gnu suppress get_type function attributes. For some reason the G_GNUC_CONST / G_GNUC_PURE attributes on generated get_type function declarations are not currently covered by the --no-gnu option. This seems unexpected, so let's get those suppressed. --- src/main.c | 11 +++++++---- tests/options.at | 3 --- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 81b22f1..295199c 100644 --- a/src/main.c +++ b/src/main.c @@ -3907,7 +3907,7 @@ print_class_block(Class *c) " * Public methods\n" " */\n"); - if (!overrode_get_type) { + if (!overrode_get_type && !no_gnu) { /* * For ordinary "static" types it should be safe to mark the * get_type implementation as const, since the get_type @@ -4315,7 +4315,8 @@ print_enum (EnumDef *enode) g_free (str); out_printf (outh, "%s_get_type()\n", funcprefix); - out_printf (outh, "GType %s_get_type (void) G_GNUC_CONST;\n\n", funcprefix); + out_printf (outh, "GType %s_get_type (void)%s;\n\n", + funcprefix, no_gnu ? "": " G_GNUC_CONST"); out_printf (out, "GType\n%s_get_type (void)\n" @@ -4380,7 +4381,8 @@ print_flags (Flags *fnode) g_free (str); out_printf (outh, "%s_get_type()\n", funcprefix); - out_printf (outh, "GType %s_get_type (void) G_GNUC_CONST;\n\n", funcprefix); + out_printf (outh, "GType %s_get_type (void)%s;\n\n", + funcprefix, no_gnu ? "" : " G_GNUC_CONST"); out_printf (out, "GType\n%s_get_type (void)\n" @@ -4443,7 +4445,8 @@ print_error (Error *enode) g_free (str); out_printf (outh, "%s_get_type ()\n", funcprefix); - out_printf (outh, "GType %s_get_type (void) G_GNUC_CONST;\n\n", funcprefix); + out_printf (outh, "GType %s_get_type (void)%s;\n\n", + funcprefix, no_gnu ? "" : " G_GNUC_CONST"); out_printf (out, "GType\n%s_get_type (void)\n" diff --git a/tests/options.at b/tests/options.at index 4fb710e..53eda46 100644 --- a/tests/options.at +++ b/tests/options.at @@ -418,9 +418,6 @@ class :Test from G:Object } ]]) -# --no-gnu is currently busted for the get_type function declaration. -AT_XFAIL_IF([:]) - AT_CHECK([gob2 test.gob]) AT_CHECK([cat test*.h test.c | grep '_GNUC_' >/dev/null], [0]) -- 2.43.2