On 6/9/21 4:47 AM, Robin Dapp wrote:
As you say, the logic is convoluted. Let's simplify it rather than
make
it more convoluted. One possibility would be to change || to | toavoid
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?
I might use > instead of !=, but sure.
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.