public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Martin Sebor <msebor@gmail.com>, Robin Dapp <rdapp@linux.ibm.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 1/2] c-family: Copy DECL_USER_ALIGN even if DECL_ALIGN is similar.
Date: Tue, 25 May 2021 11:56:28 -0400	[thread overview]
Message-ID: <a0844617-16ba-d011-9eab-7aa67998fc1c@redhat.com> (raw)
In-Reply-To: <9c5e0da6-9e62-b3e8-6d65-5fe2999ced1a@gmail.com>

On 5/25/21 11:15 AM, Martin Sebor wrote:
> On 5/25/21 4:38 AM, Robin Dapp wrote:
>> Hi Martin and Jason,
>>
>>>> The removal of the dead code looks good to me.  The change to
>>>> "re-init lastalign" doesn't seem right.  When it's zero it means
>>>> the conflict is between two attributes on the same declaration,
>>>> in which case the note shouldn't be printed (it would just point
>>>> to the same location as the warning).
>>>
>>> Agreed.
>>
>> Did I get it correctly that you refer to printing a note in e.g. the 
>> following case?
>>
>>   inline int __attribute__ ((aligned (16), aligned (4)))
>>   finline_align (int);
> 
> Yes, that's what I was referring to.
> 
>>
>> I indeed missed this but it could be fixed by checking (on top of the 
>> patch)
>>
>> diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
>> index 98c98944405..7349da73f14 100644
>> --- a/gcc/c-family/c-attribs.c
>> +++ b/gcc/c-family/c-attribs.c
>> @@ -2324,7 +2324,7 @@ common_handle_aligned_attribute (tree *node, 
>> tree name, tree args, int flags,
>>         /* Either a prior attribute on the same declaration or one
>>           on a prior declaration of the same function specifies
>>           stricter alignment than this attribute.  */
>> -      bool note = lastalign != 0;
>> +      bool note = last_decl != decl && lastalign != 0;
>>
>> As there wasn't any FAIL, I would add another test which checks for this.
> 
> That would be great, thank you!
> 
>> I find the whole logic here a bit convoluted but when there is no real 
>> last_decl, then last_decl = decl.  A note would not be printed before 
>> the patch because we erroneously warned about the "conflict" of the 
>> function's default alignment (8) vs the requested alignment (4).

Ah, the problem is that we only give this warning because of 
DECL_USER_ALIGN on last_decl, but then don't use the alignment of last_decl.

As you say, the logic is convoluted.  Let's simplify it rather than make 
it more convoluted.  One possibility would be to change || to | to avoid 
the shortcut, and then

bool note = lastalign > curalign;
if (note)
   curalign = lastalign;

Jason


  reply	other threads:[~2021-05-25 15:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-03 14:53 Robin Dapp
2021-05-10  6:32 ` Robin Dapp
2021-05-17 14:03 ` Robin Dapp
2021-05-19 22:03 ` Martin Sebor
2021-05-21 19:13   ` Jason Merrill
2021-05-25 10:38     ` Robin Dapp
2021-05-25 15:15       ` Martin Sebor
2021-05-25 15:56         ` Jason Merrill [this message]
2021-06-01 13:20           ` Robin Dapp
2021-06-01 19:11             ` Jason Merrill
2021-06-09  8:47               ` Robin Dapp
2021-06-09 21:24                 ` Jason Merrill
2021-06-01 13:24           ` Robin Dapp

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=a0844617-16ba-d011-9eab-7aa67998fc1c@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@gmail.com \
    --cc=rdapp@linux.ibm.com \
    /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).