[PATCH 1/2] c-family: Copy DECL_USER_ALIGN even if DECL_ALIGN is similar.
Robin Dapp
rdapp@linux.ibm.com
Wed Jun 9 08:47:50 GMT 2021
>>> 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;
>>
>> I went with your suggestion in the attached v2. Regtested and
>> bootstrapped on s390x, x86 and ppc64le.
>
> OK.
urg, I did not commit yet because I fiddled around with my tests again.
Using dg-notes checks (and thus being "forced" to handle all cases
individually) I realized that the above is not enough as
it reintroduces the same problem that I was originally trying to avoid:
We want to warn if lastalign == curalign but DECL_USER_ALIGN (last_decl)
!= DECL_USER_ALIGN (decl), i.e. when the user explicitly specified
__attribute__ ((aligned (8))) on s390 (see example in my first mail).
What about checking
lastalign > curalign || (lastalign == curalign && DECL_USER_ALIGN
(last_decl) != DECL_USER_ALIGN (decl))
instead and changing the associated comment?
Even then it's not really satisfactory to emit a note that complains
about "aligned (8)" at a declaration where it was not even explicitly
specified. But then, the situation is similar for other attributes as
well and we would need to explicitly store the location where an
attribute was specified first.
Regards
Robin
More information about the Gcc-patches
mailing list