<div dir="ltr">On Mon, Oct 7, 2013 at 3:09 PM, Justin Bogner <span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> writes:<br>
> This doesn't look right in the case where the attribute is on a typedef<br>
> defined inside a class in C++. Instead, I think we should only perform the<br>
> merging if Old was a TypedefNameDecl.<br>
<br>
</div>I think you meant to say "if old was a CXXRecordDecl"? This would mean I<br>
should put the [dcl.typedef] logic back where it was before and handle<br>
this separately. I think you're right.<br></blockquote><div><br></div><div>I meant what I said: we only want to merge attributes if the old declaration was also a typedef (that is, the redeclaration chain of typedefs has its own set of attributes that is independent of the attributes on the redeclaration chain for the record, and we shouldn't merge between them).</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In fact, I probably need to be more explicit about this in general. In<br>
particular, we need to handle cases like:<br>
<br>
    typedef struct __attribute__((...)) X {<br>
      ...<br>
    } X __attribute((...));<br>
<br>
I guess in this case we should go ahead and do the merge. The case where<br>
we should skip the merge is only the special case where there are no<br>
attributes on the struct, as they're all described on the typedef. Make<br>
sense?</blockquote><div><br></div><div>I think the first set of attributes should be applied to the RecordDecl and the second set should be applied to the TypedefDecl. I don't think any merging should occur in this case. We should only merge when we have a redeclaration, and the typedef declaration is not a redeclaration of the struct declaration.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
> Please also add to your testcase:<br>
><br>
> struct TDS tds2; // no warning, attribute only applies to the typedef.<br>
><br>
> ... and for good measure:<br>
><br>
> typedef struct S { char c; } S __attribute__((aligned(8)));<br>
> S a;<br>
> struct S b;<br>
> static_assert(alignof(a) == 8, "");<br>
> static_assert(alignof(b) == 1, "");<br>
<br>
</div>Will do.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">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/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>