public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Alex Henrie <alexhenrie24@gmail.com>, Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org, msebor@gcc.gnu.org
Subject: Re: [PATCH] PR c/86407 - Add option to ignore fndecl attributes on function pointers
Date: Tue, 28 May 2019 19:41:00 -0000	[thread overview]
Message-ID: <0c831fcb-9b7b-4aa3-8032-1d4b66da57b7@gmail.com> (raw)
In-Reply-To: <CAMMLpeQZdG26pjY4uu-k1HjHWfw9tDHYBmTupwfeQ21GA8XXpg@mail.gmail.com>

On 5/24/19 9:49 AM, Alex Henrie wrote:
> On Fri, May 24, 2019 at 2:01 AM Richard Biener <rguenther@suse.de> wrote:
>>
>> I'm not sure we really need a new warning for this.
> 
> On Fri, May 24, 2019 at 9:23 AM Martin Sebor <msebor@gmail.com> wrote:
>>
>> I don't think GCC makes a formal distinction between function
>> attributes that affect only function definitions vs those that
>> affect its users, or both.  It might be a useful distinction
>> to introduce, perhaps even for functions as well as variables,
>> but as it is, users (as well as GCC developers) are on our own
>> to figure it out.
> 
> Then is it preferable to simply silence Wattributes in this case?

This case being PR86407?  I'd say yes.  I think one general problem
to solve is the missing suppression for typedefs.  This could be
useful for other warnings as well.  Another is providing a knob to
control the warning when one kind of an attribute is used with
an entity of a different kind (function vs type, or variable vs
type).  Yet another might be to control warnings for individual
attributes.

> 
> On Fri, May 24, 2019 at 2:01 AM Richard Biener <rguenther@suse.de> wrote:
>>
>>> +int __attribute__((__ms_hook_prologue__)) func(); /* no warnings */
>>> +
>>
>> But this is a declaration?
> 
> On Fri, May 24, 2019 at 9:23 AM Martin Sebor <msebor@gmail.com> wrote:
>>
>> My first question is: what is the meaning of "function definition
>> attributes?"  Presumably those that affect only the definition of
>> a function and not its callers or other users?
> 
> As far as I can tell, "fndecl" is a misnomer: these attributes are
> more accurately called "function definition attributes", i.e.
> attributes that affect the assembly code of the function but do not
> affect its calling convention.

That's one possible definition but there are examples that don't
fit it (at least not very neatly).

Attribute malloc attaches only to fndecl and not its type but
doesn't affect the code for a function definition.  FWIW, I
think this is just a bug -- attribute malloc should apply
to a function type for the same reason the closely related
attribute alloc_size does.

Attribute constructor also attaches to a fndecl even though it
doesn't affect the function's codegen but that of its caller
(the runtime).  In this case, though, I'd say that's fine.
Should it be classified as a function definition attribute?

Attributes cold and hot also apply to a fndecl and not its type
but they affect both the function's definition and its callers.
I think this also makes sense.  Should they be classified as
function definition attributes?

> On Fri, May 24, 2019 at 9:23 AM Martin Sebor <msebor@gmail.com> wrote:
>>
>> Finally, with this as a prerequisite, if we decided that a warning
>> like this would be useful, tests to verify that it works for all
>> the definition attributes and not for the rest would need to be
>> added (i.e., in addition to ms_hook_prologue).
> 
> Okay, I will add tests for the other function attributes that should
> behave in the same way, commenting out the tests that will require
> more work to pass.
> 
> The end goal is to include __ms_hook_prologue__ in the WINAPI macro on
> Wine without causing spurious warnings. This will go a long way
> towards making Wine compatible with current and future Windows
> programs. Thank you for help.

Yes, I understand the goal.  I'm not sure that the proposed change
is the right way to do it.  It seems to me that a more targeted bug
to fix with the broadest benefit is that _Pragma GCC diagnostic (or
some such mechanism) cannot be used to suppress the warning for
typedefs.

Martin

  parent reply	other threads:[~2019-05-28 19:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24  3:57 Alex Henrie
2019-05-24  8:01 ` Richard Biener
2019-05-24 15:49   ` Alex Henrie
2019-05-25  6:34     ` Richard Biener
2019-05-25 17:20       ` Alex Henrie
2019-05-27  7:26         ` Richard Biener
2019-05-28 19:41     ` Martin Sebor [this message]
2019-05-29  7:16       ` Richard Biener
2019-05-30  8:28       ` Alex Henrie
2019-05-31  1:09         ` Joseph Myers
2019-05-31  5:58           ` Alex Henrie
2019-05-31  8:23             ` Richard Biener
2019-05-31 20:47               ` Alex Henrie
2019-06-03  8:25                 ` Richard Biener
2019-06-03 15:17             ` Joseph Myers
2019-05-24 15:23 ` Martin Sebor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0c831fcb-9b7b-4aa3-8032-1d4b66da57b7@gmail.com \
    --to=msebor@gmail.com \
    --cc=alexhenrie24@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).