[C PATCH] Don't reject valid code with _Alignas (PR c/61053)

Jeff Law law@redhat.com
Wed Jun 4 07:17:00 GMT 2014


On 06/02/14 00:52, Marek Polacek wrote:
> Ping.
>
> On Sun, May 25, 2014 at 11:30:51AM +0200, Marek Polacek wrote:
>> On Mon, May 05, 2014 at 10:27:03PM +0200, Marek Polacek wrote:
>>> In this PR the issue is that we reject (valid) code such as
>>> _Alignas (long long) long long foo;
>>> with -m32, because we trip this condition:
>>>
>>>     alignas_align = 1U << declspecs->align_log;
>>>     if (alignas_align < TYPE_ALIGN_UNIT (type))
>>>       {
>>>         if (name)
>>>           error_at (loc, "%<_Alignas%> specifiers cannot reduce "
>>>                     "alignment of %qE", name);
>>>
>>> and error later on, since alignas_align is 4 (correct, see PR52023 for
>>> why), but TYPE_ALIGN_UNIT of long long is 8.  I think TYPE_ALIGN_UNIT
>>> is wrong here as that won't give us minimal alignment required.
>>> In c_sizeof_or_alignof_type we already have the code to compute such
>>> minimal alignment so I just moved the code to a separate function
>>> and used that instead of TYPE_ALIGN_UNIT.
>>>
>>> Note that the test is run only on i?86 and x86_64, because we can't (?)
>>> easily determine which target requires what alignment.
>>>
>>> Regtested/bootstrapped on x86_64-unknown-linux-gnu and
>>> powerpc64-unknown-linux-gnu, ok for trunk?
>>
>> Can I backport this one to 4.9?
Yes, backporting to 4.9 is fine.
jeff



More information about the Gcc-patches mailing list