<div dir="ltr">On Tue, Aug 27, 2013 at 1:56 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</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 dir="ltr"><div class="im">On Tue, Aug 27, 2013 at 1:34 PM, Christian Wailes <span dir="ltr"><<a href="mailto:chriswailes@google.com" target="_blank">chriswailes@google.com</a>></span> wrote:<br>
<div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>It appears that attributes are not propagated from CXXRecordDecls to ClassTemplateSpecializationDecls, even when the attribute has set the Clone value to 1. The text above the Clone value in Attr.td seems to indicate that if it is set to true attributes are propagated to template instantiations. Is this a bug, or is it intended behavior and I'm missing something? </div>
</div></blockquote></div><br></div></div><div class="gmail_extra">Can you provide an example of what you're seeing? This WFM:</div><div class="gmail_extra"><br></div><div class="gmail_extra">$ echo 'template<typename T> struct __attribute__((packed)) S { char c; T t; }; S<int> s;' | ./build/bin/clang -x c++ - -Xclang -ast-dump<br>
</div><div class="gmail_extra"><div class="gmail_extra">TranslationUnitDecl 0x56230f0 <<invalid sloc>></div><div class="gmail_extra">|-TypedefDecl 0x5623630 <<invalid sloc>> __int128_t '__int128'</div>
<div class="gmail_extra">|-TypedefDecl 0x5623690 <<invalid sloc>> __uint128_t 'unsigned __int128'</div><div class="gmail_extra">|-TypedefDecl 0x5623a50 <<invalid sloc>> __builtin_va_list '__va_list_tag [1]'</div>
<div class="gmail_extra">|-ClassTemplateDecl 0x5623be0 <<stdin>:1:1, col:70> S</div><div class="gmail_extra">| |-TemplateTypeParmDecl 0x5623aa0 <col:10, col:19> typename T</div><div class="gmail_extra">
<b>| |-CXXRecordDecl 0x5623b50 <col:22, col:70> struct S</b></div>
<div class="gmail_extra"><b>| | |-PackedAttr 0x5651a30 <col:44></b></div><div class="gmail_extra">| | |-CXXRecordDecl 0x5651a70 <col:22, col:53> struct S</div><div class="gmail_extra">| | |-FieldDecl 0x5651b10 <col:57, col:62> c 'char'</div>
<div class="gmail_extra">| | `-FieldDecl 0x5651b70 <col:65, col:67> t 'T'</div><div class="gmail_extra"><b>| `-ClassTemplateSpecializationDecl 0x5651bd0 <col:1, col:70> struct S</b></div><div class="gmail_extra">
| |-TemplateArgument type 'int'</div><div class="gmail_extra"><b>| |-PackedAttr 0x5651de0 <col:44></b></div><div class="gmail_extra">| |-CXXRecordDecl 0x5651e80 prev 0x5651bd0 <col:22, col:53> struct S</div>
<div class="gmail_extra">| |-FieldDecl 0x5651f10 <col:57, col:62> c 'char'</div><div class="gmail_extra">| |-FieldDecl 0x5651fa0 <col:65, col:67> t 'int':'int'</div><div class="gmail_extra">
| |-CXXConstructorDecl 0x5652010 <col:53> S 'void (void)' inline noexcept-unevaluated 0x5652010</div><div class="gmail_extra">| | `-CompoundStmt 0x5652310 <col:53></div><div class="gmail_extra">| `-CXXConstructorDecl 0x5652170 <col:53> S 'void (const struct S<int> &)' inline noexcept-unevaluated 0x5652170</div>
<div class="gmail_extra">| `-ParmVarDecl 0x56522b0 <col:53> 'const struct S<int> &'</div><div class="gmail_extra">`-VarDecl 0x5651d80 <col:73, col:80> s 'S<int>':'struct S<int>'</div>
<div class="gmail_extra"> `-CXXConstructExpr 0x5652328 <col:80> 'S<int>':'struct S<int>' 'void (void)'</div></div></div>
</blockquote></div><br></div><div class="gmail_extra">After more discussion: the problem is that attributes on class templates are instantiated with the definition of the class template specialization, not with its declaration. That's fine for some attributes (like packed, aligned, transparent_union) but wrong for others (deprecated, may_alias, visibility, lockable, consumed).</div>
</div>