https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86407

            Bug ID: 86407
           Summary: Ignore function attributes in function type
                    declarations?
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zfigura at codeweavers dot com
  Target Milestone: ---

Wine adds several type attributes to all exposed API functions. A recent bug
related to gcc 8.1 [1] has led to the decision [2] to add the
__ms_hook_prologue__ attribute to all exposed API functions (previously done on
a case-by-case basis), by adding it to the preexisting WINAPI macro added to
all exposed API functions. However, __ms_hook_prologue__ is defined as a
function attribute and not a type attribut, due to architectural reasons I do
not fully understand [3], and so the syntax

typedef DWORD (WINAPI *APPLICATION_RECOVERY_CALLBACK)(PVOID);

expanding to

typedef unsigned int (__attribute__((__stdcall__))
__attribute__((__force_align_arg_pointer__))
__attribute__((__ms_hook_prologue__)) *APPLICATION_RECOVERY_CALLBACK)(void *);

generates the warning

warning: ‘__ms_hook_prologue__’ attribute does not apply to types
[-Wattributes]

We would like to avoid this warning, and do not want to disable -Wattributes
entirely. It seems to me that this specific warning is not really helpful in
general, as one should be able to combine all attributes applicable to a
function declaration into one macro, and in our case to avoid the warning
without any changes to GCC we would need to add a new attribute to over 50,000
entry points.

[1] https://bugs.winehq.org/show_bug.cgi?id=45199
[2] https://www.winehq.org/pipermail/wine-devel/2018-July/128938.html
[3] https://gcc.gnu.org/ml/gcc-patches/2009-09/msg01635.html

Reply via email to