[PATCH] Make getPreferredTypeAlign respect alignments specified with an aligned attribute on a typedef

Stephan Tolksdorf st at quanttec.com
Mon Feb 10 15:32:00 PST 2014


The result of alignof(T) is computed using ASTContext::getPreferredTypeAlign, which for certain types may return an alignment that is greater than the one computed by getTypeAlign. This patch teaches getPreferredTypeAlign not to change alignments specified with an aligned attribute on a typedef and thus allows the following test to compile:

typedef long long T __attribute__((aligned(1));
static_assert(alignof(T) == 1, "");

This patch does not affect the new test in CodeGen/alignment.c, but given the special handling of long long in getPreferredTypeAlign I thought it might be prudent to add a check for long long typedefs with an aligned attribute to the existing test for int typedefs.

- Stephan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: getPreferredTypeAlign.patch
Type: application/octet-stream
Size: 2762 bytes
Desc: getPreferredTypeAlign.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140210/2d2d6edd/attachment.obj>


More information about the cfe-commits mailing list