This looks like the right place to fix the bug.<br><div><br></div><div>Three comments:</div><div>- The '*' for pointer types should be on the right side.</div><div>- AlignedAttr::getMaxAlignment() isn't always super fast but I guess such typedefs are rare.  An argument could be made that getTypeInfoImpl should return a struct containing the size, alignment and whether or not the type has an explicit alignment.  Then, getPreferredTypeAlign() could take advantage of it.</div>
<div>- Both of your tests in CodeGen/alignment.c already pass without your patch.</div><div><br></div><div>-- </div><div>David Majnemer</div><div><br></div><br><div>On Tue Feb 11 2014 at 8:31:12 AM, Stephan Tolksdorf <<a href="mailto:st@quanttec.com">st@quanttec.com</a>> wrote:</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 14-02-11 00:32, Stephan Tolksdorf wrote:<br>
> The result of alignof(T) is computed using ASTContext::<u></u>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:<br>

><br>
> typedef long long T __attribute__((aligned(1));<br>
> static_assert(alignof(T) == 1, "");<br>
><br>
> 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.<br>

<br>
I've updated the patch to use getAs<> for the cast, as discussed on IRC.<br>
<br>
- Stephan<br>
<br>
______________________________<u></u>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-commits</a><br>
</blockquote>