rsmith added inline comments.

================
Comment at: include/clang/Basic/Attr.td:301
   bit DuplicatesAllowedWhileMerging = 0;
+  // Set to true if this attribute should apply to template declarations,
+  // remains false if this should only be applied to the definition.
----------------
I find this confusing -- it seems to suggest the attribute would be applied to 
the template declaration, not the templated declaration. I also think that the 
property we're modelling here is something more general than something about 
templates -- rather, I think the property is "is this attribute only meaningful 
when applied to / inherited into a defintiion?" It would also be useful to make 
clear that this only applies to class templates; for function templates, we 
always instantiate all the attributes with the declaration.

Looking through our current attribute set, it looks like at least `AbiTag` 
should also get this set, and maybe also `Visibility`. (Though I wonder if 
there would be any problem with always instantiating the full attribute set for 
a class declaration.)


================
Comment at: lib/Sema/SemaTemplate.cpp:2406-2407
+      TemplateArgLists.addOuterTemplateArguments(Converted);
+      InstantiateAttrsForDecl(TemplateArgLists,
+                              ClassTemplate->getTemplatedDecl(), Decl);
       ClassTemplate->AddSpecialization(Decl, InsertPos);
----------------
You should also presumably do this when instantiating a member `CXXRecordDecl` 
nested within a class template, and when instantiating a local class in a 
function template.

What should happen if more attributes are added between uses of the template? 
Example:

```
template<typename T> struct A;
A<int> *p;
template<typename T> struct [[deprecated]] A;
A<int> *q; // warn here?
```


https://reviews.llvm.org/D27486



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to