<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">Hi,</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">Does clang support attributes on templates? My understanding is their design is based on GCC attributes and the GCC documentation doesn't specify template support:</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><span class="Apple-tab-span" style="white-space:pre">     </span><a href="http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html" style="font-size: 10pt; ">http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html</a></div><div style="font-family: arial, helvetica, sans-serif; font-size:
 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">This also excludes support for namespace attributes. When I try to use attributes on namespaces, I get the following:</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">  </span>__attribute__((annotate("attr"))) namespace core {</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">          </span>error: expected unqualified-id</span><br></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">
        </span>namespace __attribute__((annotate("attr"))) core {</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">             </span></span><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;">error: expected identifier or '{'</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">      </span>namespace core __attribute__((annotate("attr"))) {</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">             </span>Compiles fine!</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial, helvetica,
 sans-serif; font-size: 13px;">However, when I inspect the attributes using clang::Decl::attr_begin, there are no attributes there.</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;">I'm having the same issue with templates:</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">     </span>__attribute__((annotate("attr"))) template <typename T> struct Vector {</span><br></span></div><div><span><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">            </span></span></span><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;">error: expected
 unqualified-id</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">    </span>template <typename T> __attribute__((annotate("attr"))) struct Vector {</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">          </span>Compiles fine!</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">        </span>template <typename T> struct __attribute__((annotate("attr"))) Vector {</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span"
 style="white-space:pre">          </span>Compiles fine!</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">        </span>template <typename T> struct Vector __attribute__((annotate("attr"))) {</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">               </span></span><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;">:  error: expected unqualified-id</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;">In all the cases where it compiles fine for the template case above, there are no attributes in the AST.</span></div><div><span
 style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;">Am I using the wrong means of getting the attribute list? It works for classes, fields, functions and enumerations so far.</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;"><br></span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;">Thanks,</span></div><div><span style="font-family: arial, helvetica, sans-serif; font-size: 13px;">- Don</span></div></div></body></html>