https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88766
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
gpg2 needs to be fixed then.
Looking at the source, they wrap the complit in:
#define DNS_PRAGMA_PUSH _Pragma("GCC diagnostic push")
#define DNS_PRAGMA_QUIET _Pragma("GCC diagnostic ignored \"-Woverride-init\"")
#define DNS_PRAGMA_POP _Pragma("GCC diagnostic pop")
/* GCC parses the _Pragma operator less elegantly than clang. */
#define dns_quietinit(...) \
__extension__ ({ DNS_PRAGMA_PUSH DNS_PRAGMA_QUIET __VA_ARGS__;
DNS_PRAGMA_POP })
while for clang they use
#define dns_quietinit(...) \
DNS_PRAGMA_PUSH DNS_PRAGMA_QUIET __VA_ARGS__ DNS_PRAGMA_POP
Trying:
#define DNS_PRAGMA_PUSH _Pragma("GCC diagnostic push")
#define DNS_PRAGMA_QUIET _Pragma("GCC diagnostic ignored \"-Woverride-init\"")
#define DNS_PRAGMA_POP _Pragma("GCC diagnostic pop")
#define dns_quietinit(...) \
DNS_PRAGMA_PUSH DNS_PRAGMA_QUIET __VA_ARGS__ DNS_PRAGMA_POP
struct S { int a, b; };
void
foo (void)
{
void *p = &(struct S) { .a = 0, .b = 1, .a = 0 };
void *q = &dns_quietinit ((struct S) { .a = 0, .b = 1, .a = 0 });
}
indeed fails to parse:
/tmp/h.c: In function ‘foo’:
/tmp/h.c:13:48: warning: initialized field overwritten [-Woverride-init]
void *p = &(struct S) { .a = 0, .b = 1, .a = 0 };
^
/tmp/h.c:13:48: note: (near initialization for ‘(anonymous).a’)
/tmp/h.c:14:1: error: expected expression before ‘#pragma’
void *q = &dns_quietinit ((struct S) { .a = 0, .b = 1, .a = 0 });
^ ~
(the line 13 warnings are expected and line 14 is their attempt to disable the
warning. We don't really support pragmas in the middle of expressions, but a
compound literal can't be used here.