c-family: attribute ((aligned, mode)) [PR100545]
commit0aa277bf0b4b794314ab3f11bab438d17b57465d
authorJason Merrill <jason@redhat.com>
Fri, 15 Apr 2022 20:27:05 +0000 (15 16:27 -0400)
committerJason Merrill <jason@redhat.com>
Sat, 30 Apr 2022 09:45:05 +0000 (30 05:45 -0400)
tree10bf1b97ecf8ad30860c0fadf657c01b9d289e51
parent66d1e440e14377a373d0e3d67f478cca4fd14dea
c-family: attribute ((aligned, mode)) [PR100545]

The problem here was that handle_mode_attribute clobbered the changes of any
previous attribute, only copying type qualifiers to the new type.  And
common_handle_aligned_attribute had previously set up the typedef, so when
we later called set_underlying_type it saw DECL_ORIGINAL_TYPE set and just
returned, even though handle_mode_attribute had messed up the TREE_TYPE.
So, let's fix handle_mode_attribute to copy attributes, alignment, and
typedefness to the new type.

PR c/100545

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_mode_attribute): Copy attributes, aligned,
and typedef.
* c-common.cc (set_underlying_type): Add assert.

gcc/testsuite/ChangeLog:

* c-c++-common/attr-mode-1.c: New test.
* c-c++-common/attr-mode-2.c: New test.
gcc/c-family/c-attribs.cc
gcc/c-family/c-common.cc
gcc/testsuite/c-c++-common/attr-mode-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/attr-mode-2.c [new file with mode: 0644]